/////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// facebook function
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////
		function FBLoadinLost(){
			$("#flashcontent")[0].no_login();
		}
		
		function FBgetLoginStatus(){
			FB.getLoginStatus(function(response) {
				// alert(response.session);
			  if (response.session) {
				// logged in and connected user, someone you know
				$("#flashcontent")[0].su_status(response.session);
			  } else {
				// no user session available, someone you dont know
				$("#flashcontent")[0].fail_status();
			  }
			});
		}
		
		function FBLogout(){
			FB.logout(function(response) {
			  // user is now logged out
				$("#flashcontent")[0].returnFBLogout();
			});
		}
		
		// 登入
		function GF3FBLogin(){
			//alert('GF3FBLogin');
			/* FB.login(function(response) {
				if (response.session) {
					if (response.perms) {
						// 登入也有些權限,但是權限需要都拿到才算完成
						if(response.perms.indexOf('publish_stream') > -1 && response.perms.indexOf('read_stream') > -1){
							alert('hello');
							$("#flashcontent")[0].GF3logined(response.session);
						}else{
							// 有漏權限
							FBLoadinLost();
						}
					} else {
						// 登入但沒任何權限
						FBLoadinLost();
					}
				} else {
					// 沒登入
					FBLoadinLost();
				}
			}, {perms:'read_stream,publish_stream'}); */
		}
		
		function FBAutoPublish(attobj){
			var uids = attobj.friends;
			var msg = '';
			var bl = false;
				for(var i=0;i<uids.length;i++){
					msg += uids[i]+", ";
					var publish = {
						method: 'stream.publish',
						message: "",
						display: 'iframe',
						caption: "2011.07.25-2011.08.31",
						name: "輕輕愛上GF3 幸福關鍵分享抽大獎",  
						picture: 'http://www.lumix.com.tw/images/GF3_SharePhoto.jpg',
						//picture: 'http://leoyeh.com/lumix_office/gf3event07/images/P0707023.jpg',
						link: "http://www.lumix.com.tw/", //連結的目的頁
						description: "只要看完「輕輕愛上GF3」活動影片後回答相關問題，並將活動分享給自己Facebook上的好朋友，就有機會獲得GF3數位相機等大獎，記錄並見證你的輕愛戀。分享越多，中獎機會越大！",
						actions: [{ name: '輕輕愛上GF3 幸福關鍵分享抽大獎', //其他動作顯示的文字
					   //其他動作要連結的目的頁 
					   link: 'http://www.lumix.com.tw/' }]
					};
				
					var body = 'Reading Connect JS documentation';
					//alert('msg:'+ msg );
					//FB.api('/me/feed', 'post', publish, function(response) {
					FB.api('/'+ uids[i] +'/feed', 'post', publish, function(response) {
						//alert( 'FBPublishImg'+ JSON.stringify(response) );
					  if (!response || response.error) {
						//alert('Error occured');
						//alert('發布失敗');
						bl |= true;
					  } else {
						bl |= false;
						//alert('Post ID: ' + response.id);
						//alert('已成功發布');
					  }
					});
				} 
			if(bl==true) alert('發布失敗');
			else if(bl==false) alert('已成功發布');
		}
		
		// auto發佈
		function FBAutoPublish1(attobj){
			alert('FBAutoPublish');
			var uids = attobj.friends;
			for(var i=0;i<uids.length;i++){
				var publish = {
					method: 'stream.publish',
					message: '',

					//display:'popup',
					target_id: uids[i],
					attachment: {
						media:[{type:'image', src: 'http://leoyeh.com/lumix_office/gf3event07/images/P0707023.jpg', href: 'http://www.lumix.com.tw/'}],//test
						// media:[{type:'image', src: 'http://www.pmstevent.tw/bestmom/images/good.jpg', href: 'http://www.pmstevent.tw/bestmom/images/good.jpg'}],//release
						name: '輕輕愛上GF3 幸福關鍵分享抽大獎',
						href: 'http://www.lumix.com.tw/',
						caption: '2011.07.25-2011.08.31',
						description: ('只要看完「輕輕愛上GF3」活動影片後回答相關問題，並將活動分享給自己Facebook上的好朋友，就有機會獲得GF3數位相機等大獎，記錄並見證你的輕愛戀。分享越多，中獎機會越大！')
					},
					action_links: [
						{ text:"輕輕愛上GF3 幸福關鍵分享抽大獎", href: 'http://www.lumix.com.tw/' }
					],
					user_prompt_message: ''
				};
			
				FB.api(
			  		publish,
			  		function(response) {
						alert( 'FBPublishImg'+ JSON.stringify(response) );
						// 是否發送成功，失敗原因通常是發佈次數達上限
						$("#flashcontent")[0].FBAutoPublishReturn(response);
			  		}
				);
			} 
		}
		
		function Test(attobj){
		// alert('testttt');
			 // var uname = attobj.uname;
			// var no = attobj.no;
			// var des = attobj.des;
			// var uids = new Array();
			// uids.push(attobj.uid);
			// alert(uname+ no+ des+ attobj.uid );
		}
		
		// 發佈
		function FBPublishImg(attobj){
			//alert( 'FBPublishImg' );
			 var uname = attobj.uname;
			var no = attobj.no;
			var des = attobj.des;
			var uids = new Array();
			uids.push(attobj.uid);
			//alert(uname+":"+ no+":"+ des+":"+ attobj.uid );
			// var msg = '';
			  for(var i=0;i<uids.length;i++){
			  // msg += uids[i]+", ";
				var publish = {
			 	method: 'stream.publish',
			 	message: '我覺得'+ attobj.uname +'的媽咪尚讚，你也一起來按讚！',
			  	display:'popup',
			  	target_id: uids[i],
			  	attachment: {
					media:[{type:'image', src: attobj.picture, href: attobj.picture}],
					name: 'Panasonic母親節最讚！GF2相機等超夯獎品等你拿！',
					href: 'http://apps.facebook.com/panasonic_bestmom/?fb=publish_player'+ no,
					caption: '',
					description: ( '活動期間上傳媽咪的婚紗照or懷孕照， 並寫下一句祝福，就有機會獲得GF2相機等超夯獎品， 趕快呼朋引伴前往活動頁面來幫媽咪照片按個讚！' )
			  	},
			  	action_links: [
					{ text:"Panasonic母親節最讚！", href: 'http://apps.facebook.com/panasonic_bestmom/?fb=publish_player'+ no }
			  	],
			  	user_prompt_message: ''
				};
			
				FB.api(
			  		publish,
			  		function(response) {
						// alert('FBPublishImg'+ response);
						alert( 'FBPublishImg'+ JSON.stringify(response) );
						// 是否發送成功，失敗原因通常是發佈次數達上限
						$("#flashcontent")[0].FBPublishImgReturn(response);
			  		}
				);
			}  
		}
		//isfan
		function isFan(id, pid){
			var obj = {
				method: 'pages.isFan',
				page_id: pid,
				uid: id
			};
		
			FB.api(
				obj,
				function(response) {
					$("#flashcontent")[0].fanReturn(response);
				}
			);
		}
		
		//getInfo
		function getInfo(id){
			// alert('getInfo');
			var obj = {
				method: 'users.getInfo',
				uids: id,
				fields: 'name'
			};
		
			FB.api(
				obj,
				function(response) {
					// alert( JSON.stringify(response) );
					$("#flashcontent")[0].getInfoReturn(response);
				}
			);
		}
		
		//getFriends
		function getFriends(id){
			// alert('get friends: '+ id );
			var obj = {
				method: 'friends.get',
				uids: id
			};
			FB.api(
				obj,
				function(response) {
					//alert( JSON.stringify(response) );
					$("#flashcontent")[0].getFriendsReturn(response);
				}
			);
		}
