(function () {

 NC.util.Facebook = function() {
	/* private variables and methods */
	var fbAuthResponse = null;
	var fbUid = null;
	var currentProgressDivName = "";
	var accessToken = null;
	var connectAction = -1;
 	var connected = false;
	var appConnected = false;
	var appId = -1;
	var MAX_FACEBOOK_QUERY_TIME = 1*60* 1000;
	var queryTimer = -1;

	var appInfo = [
					{
						'name': 'ncscore',
						'label': 'NC Score',
						'canvas':  'http://apps.facebook.com/ncscore',
						'invite': 'This is an invitation from NC Score',
						'inviteaction': 'Please check out NC Score',
						'selectaction': 'Invite your friends to grade their Facebook or LinkedIn profiles.'
					},
					{
						'name': 'grader',
						'label': 'Profile Grader',
						'canvas':  'http://apps.facebook.com/ncgrader',
						'invite': 'Grade your Facebook or LinkedIn profile',
						'inviteaction': 'Try Profile Grader',
						'selectaction': 'Invite your friends to grade their Facebook or LinkedIn profiles.'
					},
					{
						'name': 'grader_staging',
						'label': 'Profile Grader Beta',
						'canvas':  'http://apps.facebook.com/ncgrader-staging',
						'invite': 'Grade your Facebook or LinkedIn profile',
						'inviteaction': 'Try Profile Grader Beta',
						'selectaction': 'Invite your friends to grade their Facebook or LinkedIn profiles.'
					},
					{
						'name': 'jobs',
						'label': 'Jobs',
						'canvas':  'http://apps.facebook.com/ncjobalerts',
						'invite': 'Get jobs matched to your profile daily',
						'inviteaction': 'Try NimbleCat Jobs',
						'selectaction': 'Invite your friends to get jobs matched to their Facebook or LinkedIn profiles.'
					},
					{
						'name': 'jobs_staging',
						'label': 'Jobs Beta',
						'canvas':  'http://apps.facebook.com/ncjobalerts-staging',
						'invite': 'Get jobs matched to your profile daily',
						'inviteaction': 'Try NimbleCat Jobs Beta',
						'selectaction': 'Invite your friends to get jobs matched to their Facebook or LinkedIn profiles.'
					},
					{
						'name': 'search',
						'label': 'Search',
						'canvas':  'http://apps.facebook.com/ncsearch',
						'invite': 'A new way to find friends and grow your professional and personal network on Facebook',
						'inviteaction': 'Use NimbleCat Search',
						'selectaction': 'Find friends and grow your professional and personal network on Facebook'
					},
					{
						'name': 'search_staging',
						'label': 'Search Beta',
						'canvas':  'http://apps.facebook.com/ncsearch-staging',
						'invite': 'A new way to find friends and grow your professional and personal network on Facebook',
						'inviteaction': 'Use NimbleCat Search',
						'selectaction': 'Find friends and grow your professional and personal network on Facebook'
					},
					{
						'name': 'navigator',
						'label': 'Navigator',
						'canvas':  'http://apps.facebook.com/ncthrong',
						'invite': 'A new way to connect with your friends on Facebook',
						'inviteaction': 'Use NimbleCat Navigator',
						'selectaction': 'Find friends and grow your professional and personal network on Facebook'
					},
					{
						'name': 'navigator_staging',
						'label': 'Navigator Beta',
						'canvas':  'http://apps.facebook.com/ncthrong-staging',
						'invite': 'A new way to connect with your friends on Facebook',
						'inviteaction': 'Use NimbleCat Navigator',
						'selectaction': 'Find friends and grow your professional and personal network on Facebook'
					}
				  ];
 	
 	 	return {
			/* public methods */
			AppNcScore: 0,
			AppGrader: 1,
			AppGraderStaging: 2,
			AppJobs: 3,
			AppJobsStaging: 4,
			AppSearch: 5,
			AppSearchStaging: 6,
			AppNavigator: 7,
			AppNavigatorStaging: 8,
			
			/* connect button actions */
			FbGradeProfile: 1,
			FbLogin: 2,
			
			FbProfessionalInfo: 1,
			FbPersonalInfo: 2,
			
			init: function( _authResponse) {
				fbAuthResponse = _authResponse;
				fbUid = fbAuthResponse.userID;
				accessToken = fbAuthResponse.accessToken;
			},
			
			getAuthResponse: function() {
				return authResponse;
			},
			
			getFbUid: function() {
				return fbUid;
			},
			
			getAccessToken: function() {
				return accessToken;
			},
			
			isLoggedIn: function() {
				return( fbAuthResponse != null ? true: false);
			},
			
			setConnectButtonAction: function(actionValue){
				connectAction = actionValue;
			},
			
			getConnectButtonAction: function(){
				return connectAction;
			},
			
			setConnected: function(connectedValue){
				connected = connectedValue
			},
			
			isConnected: function(){
				return connected;
			},
			
			setAppConnected: function(connectedValue){
				appConnected = connectedValue
			},
			
			isAppConnected: function(){
				return appConnected;
			},
			
			setAppId: function(_appId){
				appId = _appId;
			},
			
			getAppId: function(){
				return appId;
			},
			
			getAppName: function(){
				if (appId == -1) {
					return null;
				}
				else {
					return appInfo[appId].name;
				}
			},
			
			getAppCanvasByAppId: function(thisAppId){
				if (typeof thisAppId == 'undefined') {
					return null;
				}
				else {
					return appInfo[thisAppId].canvas;
				}
			},
			
			getAppLabel: function(){
				if (appId == -1) {
					return null;
				}
				else {
					return appInfo[appId].label;
				}
			},
			
			insertFacebookGradeProfileButton: function(buttonDivName, appName){
				var buttonDiv = document.getElementById(buttonDivName);
				if (buttonDiv != null) {
					if (connected) {
						buttonDiv.innerHTML = '<a href="#" onclick="NC.promo.PromoManager.startFacebookPromo()"><img src="../imagesv2/ext/fbGradeProfile.png" border=0></a>';
					}
					else {
						buttonDiv.innerHTML = '<a href="#" onclick="NC.promo.PromoManager.startFacebookPromo()"><img src="../imagesv2/ext/fbGradeProfile.png" border=0></a>';
					}
				}
			},
			
			insertFacebookLoginButton: function(buttonDivName, userState){
				var buttonDiv = document.getElementById(buttonDivName);
				if (buttonDiv != null) {
					var altText = 'Login with your Facebook account. Its fast, easy and keeps your account info secure.';
					if (connected) {
						buttonDiv.innerHTML = '<a href="#" title="' + altText + '" onclick="NC.promo.PromoManager.startFacebookLoginPromo(\'' + userState + '\')"><img src="../imagesv2/ext/fbLogin.png" border=0></a>';
					}
					else {
						buttonDiv.innerHTML = '<a href="#" title="' + altText + '" onclick="login()"><img src="../imagesv2/ext/fbLogin.png" border=0></a>';
					}
				}
			},
			
			
			
			showInviteFriendsDialog: function(){
				// get dialog display and show the invite friends dialog in it
				/*
				var dialog = document.getElementById('FBFormWrapper');
				dialog.style.width = '760px';
				dialog.style.height = '800px';
				dialog.style.display = 'block';
				NC.util.Facebook.insertInviteFriendsDialog('FBFormWrapper');
				*/
			},
			
			insertInviteFriendsDialog: function(divName){
				/*
				var info = appInfo[appId];
				var fbml = '';
				fbml += '<fb:serverFbml style="width: 760px;">';
				fbml += '<script type="text/fbml">';
				fbml += '<fb:fbml>';
				fbml += '<fb:request-form';
				//				fbml += '    action="' + info.canvas + '"';
				fbml += '    action=""';
				fbml += '    target="_top"';
				fbml += '    method="POST"';
				fbml += '    invite="true"';
				fbml += '    type="' + info.label + '"';
				fbml += '    content="' + info.invite;
				fbml += ' 				<fb:req-choice url=\'' + info.canvas + '\'';
				fbml += '       			label=\'' + info.inviteaction + '\' />';
				fbml += '			 "';
				fbml += '>';
				
				fbml += '<fb:multi-friend-selector';
				fbml += '    target="_top"';
				fbml += '    cols="5"';
				fbml += '    rows="3"';
				fbml += '	showborder="false"';
				fbml += '	actiontext="' + info.selectaction + '">';
				fbml += '</fb:request-form>';
				fbml += '</fb:fbml>';
				
				fbml += '</script>';
				fbml += '</fb:serverFbml>';
				
				var div = document.getElementById(divName);
				div.innerHTML = fbml;
				NC.util.Event.onContentReady(divName, function(){
					var fbDiv = document.getElementById(divName);
					if (FB.XFBML.Host.parseDomTree) {
						setTimeout(FB.XFBML.Host.parseDomTree, 250);
					}
				});
				*/
			},
			
			showJobAlertAction: function(divName){
				var el = document.getElementById(divName);
				el.innerHTML = '<a href="#" onclick="onShowJobAlerts()">Show alerts</a>';
			},
			
			showJobMapAction: function(divName){
				var el = document.getElementById(divName);
				el.innerHTML = '<a href="#" onclick="onShowJobMap()">Show map</a>';
			},
			
			getUserName: function(getEmail, onComplete){
				var queryStr = 'SELECT name ';
				if (getEmail) {
					queryStr += ', email ';
				}
				queryStr += ' from user where uid = ' + fbUid;

				FB.api(
				  {
				    method: 'fql.query',
				    query: queryStr
				  },
				  function(rows) {
					if (rows != null && rows.length >= 1) {
						var email = '';
						var name = '';
						if (getEmail) {
							email  = rows[0].email;
						}
						onComplete(rows[0].name, email);
					}
					else {
						onComplete('', '');
					}
				  }
				);
				
			},
			
			PermUserWorkHistory: "user_work_history",
			PermUserEducationHistory: "user_education_history",
			PermFriendsWorkHistory: "friends_work_history",
			PermFriendsEducationHistory: "friends_education_history",
			PermEmail: "email",
			PermUserInterests: "user_interests",
			PermFriendsInterests: "friends_interests",
			PermUserActivities: "user_activities",
			PermFriendsActivities: "friends_activities",
			PermUserLocation: "user_location",
			PermFriendsLocation: "friends_location",
			PermPublishStream: "publish_stream",

			
			StrEducationHistory : 'education_history',
			StrInstitutionName : 'name',
			StrDegreeYear : 'year',
			StrDegreeConcentrations : 'concentrations',
			StrDegreeName : 'degree',

			StrEmploymentHistory : 'work_history',
			StrLocation : 'location',
			StrCity : 'city',
			StrState : 'state',
			StrCountry : 'country',
			StrCompanyName : 'company_name',
			StrPosition : 'position',
			StrDescription : 'description',
			StrStartDate : 'start_date',
			StrEndDate : 'end_date',
			StrName : 'name',
			StrProxiedEmail : 'proxied_email',
			StrEmail : 'email',
			StrLineBreak : '<br>',
			StrFacebookHeaders : '***Facebook Resume Headers***',
			StrEmploymentCount : 'EmploymentCount:',
			StrAvgEmpDescLength : 'AvgEmpDescLength:',
			StrEducationCount : 'EducationCount:',
			StrHeaderTerminator : ':',

			
			reformatFacebookDate:function( dateStr) {
				var date = dateStr.split('-');
				if (date.length == 2) {
					var year = parseInt( date[0]);
					if (year == 0) {
						return 'present';
					}
					else {
						return date[1] + '/' + '1' + '/' + date[0];
					}
				}
				else {
					return dateStr;
				}
			},

			formatResumeForParser: function( jContent) {
				if (jContent.length == 0) {
					return '';
				}
				var resume = '';
				resume += jContent[this.StrName] + this.StrLineBreak;
				resume += jContent[this.StrEmail] + this.StrLineBreak;
				resume += '<br><br>'; // separator
		        var employment =  jContent[this.StrEmploymentHistory];
				var employmentCount = employment.length;
				var employmentSize = 0;
				if (employment.length > 0) {
					resume += 'Experience';
			        for (m = 0; m < employment.length; m++) {
						resume += this.StrLineBreak;
			        	var em = employment[m];
			        	resume += this.StrLineBreak;
						var estart = NC.lang.trim(em[this.StrStartDate]);
						var eend = NC.lang.trim(em[this.StrEndDate]);
						if (estart.length == 0) {
							estart = "Unknown";
						}
						else {
							estart = this.reformatFacebookDate( estart);
						}
						if (eend.length == 0) {
							eend = "Present";
						}
						else {
							eend = this.reformatFacebookDate( eend);
						}
						resume += estart + ' - ' + eend + ', ';
						resume += em[this.StrPosition] + ', ' + em[this.StrCompanyName];
						var loc = em[this.StrLocation];
						if (loc.length > 0) {
							resume += ', ' + loc[this.StrCity] + ', ' + 
											  loc[this.StrState] + ', ' + 
											  loc[this.StrCountry];
						}
						resume += this.StrLineBreak;
						resume += em[this.StrDescription];
						employmentSize += em[this.StrDescription].length;
			        }
				}
				resume += this.StrLineBreak;
				
				
				var education = jContent[this.StrEducationHistory];
				var educationCount = education.length;
				resume += this.StrLineBreak;
				resume += this.StrLineBreak;
				resume += 'Education';
				resume += this.StrLineBreak;
				if (education.length > 0) {
			        for (e = 0; e < education.length; e++) {
					resume += this.StrLineBreak;
			        	var ed = education[e];
						resume += ed[this.StrInstitutionName] + ', ';
						resume += ed[this.StrDegreeName] + ', ';
						var concentrations = ed[this.StrDegreeConcentrations];
						if (concentrations.length > 0) {
							for (c = 0; c < concentrations.length; c++) {
								if (c > 0) {
									resume += ', ';
								}
								resume += concentrations[c];
							}
						}
						resume += ', ';
						resume += ed[this.StrDegreeYear];
			        }
				}
				resume += this.StrLineBreak + this.StrFacebookHeaders+  this.StrLineBreak;
				resume += this.StrEmploymentCount + employmentCount  + this.StrHeaderTerminator +  this.StrLineBreak;
				resume += this.StrAvgEmpDescLength + employmentSize/ employmentCount  + this.StrHeaderTerminator +  this.StrLineBreak;
				resume += 'EducationCount:'  + educationCount  + this.StrHeaderTerminator + this.StrLineBreak;
				return resume;
			},
			
			getQueryTimer: function() {
				return queryTimer;
			},
			
			resetQueryTimer: function() {
				queryTimer = -1;
			},
			
	 		showFacebookErrorContent: function( divId) {
	 			var div = document.getElementById( NC.widget.MessageBox.makeContentDivName());
	 			var content = '<div class="dialog"><h2>Oops!</h2>';
	 			content += '<p>Facebook did not give us any information about your friends yet. Could you please return to Throng later?</p>';
	 			content += '</p></div>';
	 			div.innerHTML = content;
	 		},
	 		
	 		showFacebookError: function() {
					var callback =
					{
						ok: function() { 
						}
		  			};
				NC.widget.MessageManager.showDialog('ncfunc:showFacebookErrorDialog', NC.util.AjaxDialogDisplay.DialogWrapper, callback, true, -1, -1, -1, true, -1, false);
			},

	 		
			

			populateSocialGraph: function( progressDivName, deleteExistingInfo, updateActivities, onComplete, refreshOffer){
				queryTimer = setTimeout( function() {
				  		NC.util.Facebook.showFacebookError();
				},MAX_FACEBOOK_QUERY_TIME);
				currentProgressDivName = progressDivName; // save for later
				var queryStr = 
				'SELECT uid, profile_url, name, education_history, work_history from user where uid = ' + fbUid +
				' or uid in (SELECT uid2 FROM friend WHERE uid1 = ' + fbUid + ')';

				FB.api(
				  {
				    method: 'fql.query',
				    query: queryStr
				  },
				  function(rows) {
				  		if (NC.util.Facebook.getQueryTimer() != -1) {
				  			clearTimeout(NC.util.Facebook.getQueryTimer());
				  			NC.util.Facebook.resetQueryTimer();
				  		}
				  		var professionalGraph = "";
						if (rows != null && rows.length > 0) {
							professionalGraph = NC.lang.JSON.stringify( rows);
							NC.widget.StateManager.setUploadedFbWorkFlag();
						}
						else {
							NC.util.Status.showThrongMessage( "<p>Oops! Facebook did not give us any information about your friends. Could you please return to Throng later?</p>", "NetworkContent");
						}
						NC.util.Facebook.populateAuxiliarySocialGraph( progressDivName, deleteExistingInfo, onComplete, refreshOffer, professionalGraph);
					}
				);
			},
			
			populateAuxiliarySocialGraph: function( progressDivName, deleteExistingInfo, onComplete, refreshOffer, professionalGraph){
				queryTimer = setTimeout( function() {
				  		NC.util.Facebook.showFacebookError();
				},MAX_FACEBOOK_QUERY_TIME);

				var queryStr = 'SELECT uid, profile_url, name, activities, interests, current_location from user where uid = ' + fbUid +
                            ' or uid in (SELECT uid2 FROM friend WHERE uid1 = ' + fbUid + ')';
				FB.api(
				  {
				    method: 'fql.query',
				    query: queryStr
				  },
				  function(rows) {
			  		if (NC.util.Facebook.getQueryTimer() != -1) {
			  			clearTimeout(NC.util.Facebook.getQueryTimer());
			  			NC.util.Facebook.resetQueryTimer();
			  		}
				  	var personalGraph = "";
					if (rows != null && rows.length > 0) {
						personalGraph = NC.lang.JSON.stringify( rows);
						NC.widget.StateManager.setUploadedFbActivitiesFlag();
					}
					else {
						NC.util.Status.showThrongMessage( "<p>Oops! Facebook did not give us any information about your friends. Could you please return to Throng later.</p>", "NetworkContent");
					}
					NC.util.Facebook.populateProfile( progressDivName, deleteExistingInfo, onComplete,refreshOffer, professionalGraph, personalGraph);
				  }
				);
			},
			
			onUpdateComplete: function(){
				/*
				var callback = {
					ok: function(){
						NC.widget.NetworkManager.refreshNetworkAfterUpdate(false, function() {
							setTimeout(function(){
								if (NC.widget.StateManager.hasUploadedLinkedIn() == true) {
									NC.util.LinkedIn.authorizeAndUpload( 'NetProgressDiv', false, null, false);
								}
								else {
									NC.util.LinkedIn.askUploadLinkedIn();
								}
							}, 1000);
						});
					},
					
					cancel: function(){
						if (NC.widget.StateManager.hasUploadedLinkedIn() == true) {
							NC.util.LinkedIn.authorizeAndUpload( 'NetProgressDiv', false, null, false);
						}
						else {
							NC.util.LinkedIn.askUploadLinkedIn();
						}
					}
				};
				NC.widget.NetworkManager.showMessage("facebookUpdateAvailable.php", 500, true, callback);
				*/
				if (NC.widget.StateManager.hasUploadedLinkedIn() == true) {
					NC.util.LinkedIn.authorizeAndUpload( 'NetProgressDiv', false, null, false);
				}
				else {
					NC.util.LinkedIn.askUploadLinkedIn();
				}
				NC.widget.StateManager.clearFacebookUpdatedFlag();
			},
			
			populateProfile: function(progressDivName, deleteExistingInfo, onComplete, refreshOffer, professionalGraph, personalGraph){
				var queryStr = 'SELECT uid, profile_url, name, email, education_history, work_history from user where uid = ' + fbUid;
				;
				FB.api({
					method: 'fql.query',
					query: queryStr
				}, function(rows){
					var profile = "";
					if (rows != null && rows.length > 0) {
						var profile = NC.lang.JSON.stringify(rows);
					}
					NC.widget.StateManager.clearFacebookUpdatedFlag(
						function() { // on success
							var callback = {
								success: function(o){
									NC.widget.StateManager.setUploadedFbActivitiesFlag();
									if (onComplete != null) {
										onComplete();
									}
									if (refreshOffer) {
										setTimeout(function(){
											NC.widget.OfferPaneManager.refresh();
										}, 1000);
									}
									/*
									 * start timer to check
									 */
									NC.widget.StateManager.waitTillFlagSet( NC.widget.StateManager.UPDATEDFACEBOOK, NC.util.Facebook.onUpdateComplete);
								},
								failure: function(o){
								//								alert( "Connect activities and interests failed");
								},
								scope: this
							};
		//					NC.util.Status.showProgress(progressDivName, 'Update interests');
							var url = './connectSocialGraph.php';
							var jsonResults = 'flags=1&del=' + deleteExistingInfo +
							'&professional=' +
							encodeURIComponent(professionalGraph) +
							'&personal=' +
							encodeURIComponent(personalGraph) +
							'&profile=' +
							encodeURIComponent(profile);
							var connection = new NC.util.AjaxConnection('POST', url, jsonResults);
							connection.executeMethod(callback);
						},
						function() { // on failure
							alert("Oops! Something bad happened(1003)");
						}
					)
				});
			},
			
			
			
			
			updateFacebookNetwork: function(progressDivName, refresh, onUpdate){
				var callback = {
					success: function(o){
						var r = NC.lang.JSON.parse(o.responseText);
						// only run the update if it has been more than one day since the last update
						if (r.daysSince > 0) {
							this._updateFacebookNetwork( progressDivName, refresh);
							if (onUpdate != null) {
								onUpdate( true);
							}
						}
						else {
							if (onUpdate != null) {
								onUpdate( false);
							}
						}
					},
					failure: function(o){
						this._updateFacebookNetwork( progressDivName, refresh);
							if (onUpdate != null) {
								onUpdate( true);
							}
					},
					scope: this
				};
				var url = './getDaysSinceLastUpdate.php';
				var connection = new NC.util.AjaxConnection( 'GET', url, '');
				connection.executeMethod( callback);
			},
			
			
			_updateFacebookNetwork: function(progressDivName, refresh){
				// once the network has been displayed - update the professional and/or personal networks
				var updateMessage = "We're updating your throngs from Facebook and LinkedIn."
				NC.util.Status.showThrongProgressAutoHide(updateMessage, "NetworkContent");
				NC.util.Facebook.populateSocialGraph(progressDivName, 1, true, function(){
					if (refresh) {
						NC.widget.NetworkManager.refreshNetwork();
					}
				}, false);
			},
			
			gradeUserProfile: function( promoDivName){
				var queryStr = 
				'SELECT name, email, education_history, work_history from user where uid = ' + fbUid ;
				FB.api(
				  {
				    method: 'fql.query',
				    query: queryStr
				  },
				  function(rows) {
					if (rows != null && rows.length > 0) {
						var callback =
						{
			  				success:function( o) {
								NC.widget.StateManager.setUploadedResumeFlag(); // set ui state flag for resume uploaded
								NC.widget.ResumeUploadManager.processEncodedProfile( o.responseText);
									var docRoot = NC.widget.ResumeUploadManager.getDomRoot();
									NC.promo.PromoManager.getPromo().setDocRoot( docRoot);
									var ncScore = NC.util.Dom.extractField( docRoot, NC.widget.ResumeWizard.StrNCScore);
									var offers = NC.offer.OfferManager.constructOffer( promoDivName,docRoot, NC.offer.OfferManager.SourceFacebook);
									NC.offer.OfferManager.setOffers( offers);
									NC.offer.OfferManager.startNextOffer();
			  				},
			  				failure:function( o) {
								alert( "grade profile failed");
			  				},
							scope: this    				
						};
						var profile = NC.util.Facebook.formatResumeForParser( rows[0]);
						var url = './processFacebookProfile.php';
						profile= 'profile=' + encodeURIComponent(profile);
						var connection = new NC.util.AjaxConnection( 'POST', url, profile);
						connection.executeMethod( callback);
					}
				  }
				);

				FB.Facebook.apiClient.fql_query(query, function(rows){
				});
			},
			
			
			showAddFriendDialog: function(friendId){
				gaPageTracker._trackEvent(NC.promo.PromoManager.getCpid(), "Click", "ThrongAddFriend");
					/*
						 FB.Connect.showAddFriendDialog( friendId, function() {
		 
						 });
		 			*/
				FB.ui({
					method: 'friends',
					id: friendId
				}, 
				function(response){
					if (response) {
						if (response.action == 1) {
						}
						else {
						
						}
					}
				});
			},
			
			showFeedDialog: function( fUid, url, linkName, pictureSrc, linkDescription, actionLinks) {
				var parms = 
				   {
				   	method: 'feed',
					name: linkName,
					link: url,
					picture: pictureSrc,
					caption: '',
					description: linkDescription,
					actions: actionLinks
				   };
				if (fUid != null && fUid.length > 0) {{
					parms.to = fUid;
				}}
				FB.ui(
				   parms, 
				   function(response) {
				     if (response && response.post_id) {
				     } else {
				     }
				   }
				 );
			},
			
			showShareMapDialog: function( fUid, url) {
				gaPageTracker._trackEvent(NC.promo.PromoManager.getCpid(), "Click", "ThrongShare"); 
				var label= null;
				var parms = '';
				if (!NC.lang.isUndefined(NC.widget.NetworkManager)) {
					label = NC.widget.NetworkManager.makeThrongLabel();
				}
				var description = '';
				if (label == null) {
					description = 'I mapped my social networks with Throng. ' +
					'Now I can see my connections in one place, and I can quickly identify new friends to connect with based on where they work or how they play. How will you use Throng? http://apps.facebook.com/ncthrong';
				}
				else {
					description = 'I mapped my social networks with Throng. This map shows people in my networks who ' + label;
					description += '. Now I can see my connections in one place, and I can quickly identify new friends to connect with based on where they work or how they play. How will you use Throng? http://apps.facebook.com/ncthrong';
				}
				var names = NC.UserName.split(' ');
				var linkName = names[0] + ' shared a throng';
				var actionLinks = new Array(1);
				actionLinks[0] = {};
				actionLinks[0].name = names[0] + '\'s throng';
				actionLinks[0].link = url;
				
				this.showFeedDialog( fUid, url, linkName, NC.SiteRoot + "imagesv2/throng_75x75_1.png", description, actionLinks);

			}, /* end */
			
			showInviteThrongDialog: function( fUid, url) {
				gaPageTracker._trackEvent(NC.promo.PromoManager.getCpid(), "Click", "ThrongShare"); 
				var label= null;
				var parms = '';
				if (!NC.lang.isUndefined(NC.widget.NetworkManager)) {
					label = NC.widget.NetworkManager.makeThrongLabel();
				}
				var names = NC.UserName.split(' ');
				var linkName = names[0] + ' shared a Throng map';
				var description = '';
				if (label == null) {
					label = 'I mapped my social networks with Throng. ' +
					'Join me on Throng and we\'ll be able to give and receive help with career moves, ' +
					'and professional introductions and learn more about what our friends enjoy. How will you use Throng? http://apps.facebook.com/ncthrong';
				}
				else {
					label = 'I mapped my social networks with Throng. ' +
					'This map shows my friends who ' + label;
					description += '. Join me on Throng and we\'ll be able to give and receive help with career moves, ' +
					'and professional introductions and learn more about what our friends enjoy. How will you use Throng? http://apps.facebook.com/ncthrong';
				}
				var actionLinks = new Array(1);
				actionLinks[0] = {};
				actionLinks[0].name = names[0] + '\'s Throng map';
				actionLinks[0].link = url;
				
				this.showFeedDialog( fUid, url, linkName, NC.SiteRoot + "imagesv2/throng_75x75_1.png", description, actionLinks);

			}, /* end */
						
			logout: function( redirect) {
				if (fbAuthResponse != null) {
					FB.logout(function(response) {
  						window.location = redirect;
					});
				}
				else {
					window.location = redirect;
				}
			}

		}
  }	
();

})(); 	
 

