

		
		FB.init("d53f5fdc416b199daa092a53722ef02b", "xd_receiver.htm");
		
		/*
			"d53f5fdc416b199daa092a53722ef02b" is the API key.
			"xd_receiver.htm" is where the xd_reciever is located (in this case: http://www.wytzeaaa.nl/fbConnect/xd_receiver.htm).
			It can also be relative to the html-page, by omitting the first '/'.
		*/
		


		function thisMovie(movieName) {
			 if (navigator.appName.indexOf("Microsoft") != -1) {
				 return window[movieName];
			 } else {
				 return document[movieName];
			 }
		 }
		 
		 function sendToActionScript(value) {
			thisMovie("PPurse").sendToActionScript(value);
			//"PPurse" refers to the Flash Object ID/name.
		 }
     
	
		function logIn()
		{
			FB.Connect.requireSession(postPersonality);
		}
	
		function sendToJavaScript(value, value2)
		{
		
			
	
			 switch(value)
			 {
			 
				case "AutoConnect":
	
				FB.Connect.get_status().waitUntilReady( function(status) { 
				
				switch ( status ) {
				case FB.ConnectState.connected:
				//user is al ingelogd
				FB.Connect.ifUserConnected(userLoggedIn); 
				FB.Connect.requireSession(userLoggedIn);
				break;
				}}	);
				break;
			 
				case "Connect":
				FB.Connect.ifUserConnected(userLoggedIn); 
				FB.Connect.requireSession(userLoggedIn);
				break;
				
				case "Post":
				postFeed(value2);
				break;
				
				case "LogOut":
				FB.Connect.logout(userLoggedOut);
				break;
				
				case "GetPortalGroupAndLanguage":
				//alert("GET PROTYALGROUP and LANGUAGE");
				getPortalGroupAndLanguage();
				break;
			}

		}
		
		function statusReady(status)
		{
			alert(status);

			alert("Get status = ready");
			alert(status);
			

		}
	 
	 
		 
		 function postFeed(v)
		 {
			var template_data = {"personality":v.p, "description":v.d, "images":[{"src":"http://www8.agame.com/games/flash/p/professor_purse/"+v.i, "href":"http://www.girlsgogames.com/game/Professor_Purse.html?utm_medium=brandedgames_external&utm_campaign=Professor_Purse&utm_source=facebook.com&utm_content=facebook_profile"}]};
			FB.Connect.showFeedDialog("148227807856", template_data, "", "", null, null, feedPosted);
			//"148227807856" is Template Bundle ID.
		 }
		 
		 function feedPosted()
		 {
			thisMovie("PPurse").sendToActionScript("FEED_POSTED", "");
		 }
	 
		 function userLoggedIn()
		 {
		

			var uid = FB.Facebook.apiClient.get_session().uid ;
			var sql = "SELECT name, pic_square FROM user WHERE uid ="+uid;
			FB.Facebook.apiClient.fql_query(sql, function(result, ex) {


				
				var userName= result[0]['name'];
				var userPic= result[0]['pic_square'];

				thisMovie("PPurse").sendToActionScript("USER_LOGGED_IN", userName);
				thisMovie("PPurse").sendToActionScript("USER_PIC", userPic);

			});
		}
		 function userLoggedOut()
		 {
			thisMovie("PPurse").sendToActionScript("USER_LOGGED_OUT", "");
		 }
		 
		 
		 //portalgroup & language
		 
		 function getPortalGroupAndLanguage()
		 {
			thisMovie("PPurse").sendToActionScript("LANGUAGE", getParameter(window.location.search.substring(1), "l"))
			thisMovie("PPurse").sendToActionScript("PORTALGROUP", getParameter(window.location.search.substring(1), "p"));

		 }
		 
		 //get postvars without using php
		 
		 function getParameter ( queryString, parameterName )
		 {
		   // Add "=" to the parameter name (i.e. parameterName=value)
		   var parameterName = parameterName + "=";
		   if ( queryString.length > 0 ) {
			  // Find the beginning of the string
			  begin = queryString.indexOf ( parameterName );
			  // If the parameter name is not found, skip it, otherwise return the value
			  if ( begin != -1 ) {
				 // Add the length (integer) to the beginning
				 begin += parameterName.length;
				 // Multiple parameters are separated by the "&" sign
				 end = queryString.indexOf ( "&" , begin );
			  if ( end == -1 ) {
				 end = queryString.length
			  }
			  // Return the string
			  return unescape ( queryString.substring ( begin, end ) );
		   }
		   // Return "null" if no parameter has been found
		   return "null";
		   }
		}
