/** HDDIGITAL FB JS HELPER 
 ** version 1
 ** http://hddigital.com.vn
*/
var FbHelper=
{
	title: "A LÊ HẤP DẬY THÔI <b>SUPER 5</b>",
	
	short_info:"",
	
	base_url:appurl,
	
	link_title: "đánh thức super 5 ngay",
		
	publishMain:function()
	{
		//FbHelper.publishText("http://colgateplax.com.vn/site/index/share");
				
		message	=	FbHelper.title;
		
		actionLink =[{ text: FbHelper.link_title, href: FbHelper.base_url }];
		var Description = 'A lê hấp! Cùng đánh thức Super 5 với game <b>\"A lê hấp dậy thôi\"</b>. Sẽ có nhiều phần quà \"nặng ký\" cho các bạn đánh thức Super 5 cừ khôi. Nhanh tay lên, không thì cả bọn sẽ trễ học mất.';
		attachment={
					name:FbHelper.title,
					caption: "Tham gia ngay",
					description:Description,
					media:[{
    						type: "flash", 
							swfsrc: mainurl+"data/banner_facebook.swf", 
							imgsrc: mainurl+"data/alehap.png", 
							width: "80", 
							height: "60",
							expanded_width: "500", 
							expanded_height: "290"}]										
					};
					
		FB.ui(
			   {
				 method: 'stream.publish',
				 message: message,
				 attachment: attachment,
				 //media:media,
				 action_links:actionLink ,
				 user_message_prompt: FbHelper.title
			   },
			   function(response) {
				 if (response && response.post_id) {
					 
					 //alert(done);
				   //alert('Post was published.');
				 } else {
				   //alert('Post was not published.');
				 }
			   }
 			);
			

	},
	publishText:function(sharelink)
	{
		var axel = Math.random() + "";
		
		var a = axel * 10000000000000;
		
		window.open ("http://www.facebook.com/sharer.php?fb_sig_api_key=1e13d7bc4932d9bb2d38522920d68697&wid=259692307376567&u="+sharelink +"?" + a+"&t="+FbHelper.title,"mywindow");
	},
	publishItem:function(ItemID)
	{
		//ItemID= 1;	

				  
		url	=	appurl + 'process/remotegetitem/';		
		
		$.post(url,{shd:shd,id:ItemID},FbHelper.parseResponse);

	},
	parseResponse:function(response)
	{

		//alert(response);
		var img ="";
		
		var vid = "";
		
		var title = "";
		
		var membername = "";
		
		var itemtype = "";
		
		var itemgenre = "";
		
		if(response!="")
		{
			$(response).find("item").each(function()
			{
				ItemID	= 	$(this).find("id").text();
				
				img 	=	$(this).find("avatar").text();
						
				vid 	=	$(this).find("song").text();
				
				membername = $(this).find("membername").text();
				
				itemtype = $(this).find("type").text();
				
				itemgenre = $(this).find("genre").text();
				
				
				
			});
		}
		
		var Description = "text <b>" + membername + "</b> text <b>" + membername + "</b> nhé. text <b>text</b> text";
		
		
		//var Description = "Cả nhà yên lặng lắng nghe <b>" + membername + "</b> hát cho cảm xúc mỗi ngày cùng Palmolive nào copy link bên dưới để xem" + mainurl + "index/index/itemid/" + ItemID;
		
		var Caption = "<b>" + membername + "</b>" + " text";
		
		if(img!="" && vid!="")
		{
		
			message="Xin chào ";
			
			actionLink =[{ text: FbHelper.link_title, href: appurl + "index/index/itemid/" + ItemID }];
			
			if(itemtype=="record")
			{
				attachment={				
							name:FbHelper.title,
							caption: Caption,
							description:Description,
							media:[{
									type: "flash", 
									swfsrc: mainurl + "data/playerfb.swf?link="+ vid + "&genre=" + itemgenre + "&siteurl=" + mainurl, 
									imgsrc: mainurl + img, 
									width: "80", 
									height: "60",
									expanded_width: "500", 
									expanded_height: "290"}]
							};
			}
			else
			{
				attachment={				
							name:FbHelper.title,
							caption: Caption,
							description:Description,
							media:[{
									type: "flash", 
									swfsrc: mainurl + "data/player.swf?src="+ vid + "&type=stream&autoPlay=true&bufferTime=2&width=500&height=290&scaleMode=zoom", 
									imgsrc: mainurl + img, 
									width: "80", 
									height: "60",
									expanded_width: "500", 
									expanded_height: "290"}]
							};
			}
			FB.ui(
				   {
					 //display: "iframe",
					 method: 'stream.publish',
					 message: message,
					 attachment: attachment,
					 
					 //media:media,
					 action_links:actionLink ,
					 user_message_prompt: FbHelper.title
				   },
				   function(response) {
					 if (response && response.post_id) {
						 
						 //alert(done);
					   //alert('Post was published.');
					 } else {
					   //alert('Post was not published.');
					 }
				   }
				);
			}
	},
	initGA:function()
	{
		_gaq.push(['_trackPageview', '/home']); 
_gaq.push(['_trackPageview', '/home/event']); 
_gaq.push(['_trackPageview', '/home/product']); 
_gaq.push(['_trackPageview', '/home/tc']); 
	}
}
//$(document).ready(function(){FbHelper.publishItem(1)});
//$(document).ready(function(){FbHelper.publishMain()});
