﻿/* FACEBOOK FUNCTIONS */
/* <div onclick="sharePage('URL PARA IMAGEM', 'A descrição da Janela', '/sectorautomovel/default.aspx')">Click Me</div> */

	window.fbAsyncInit = function() {
		FB.init({appId: '161534917207896', status: true, cookie: true,xfbml: true});
	};
	
	(function() {
		var e = document.createElement('script'); e.async = true;
		e.src = document.location.protocol +
		'//connect.facebook.net/en_US/all.js';
		document.getElementById('fb-root').appendChild(e);
	}());


	var websiteURL = "http://www.gonatural.pt/";
	
	function sharePage(imgPath, descricao, pageURL, pageName){      
	    var attachment = {
					  'name' : 'Go Natural',
					  'href' : 'http://www.facebook.com/pages/Go-Natural/106636186060056',
					  'caption' : '{*actor*} gosta da galeria de imagens da Go Natural - '+pageName+'',
					  'description' : descricao,
					  'media' : [{'type' : 'image', 'src' : websiteURL+''+imgPath, 'href' : websiteURL+'#/'+pageURL}] //A imagem tem de estar online!
					  };
		var action_links = [{'text' : 'Saiba mais +','href' : websiteURL+'#/'+pageURL}];                         
		
		 FB.ui(
		   {
		     method: 'stream.publish',
		     attachment: attachment,
		     action_links: action_links,
		     user_prompt_message: '{*actor*} gosta de Go Natural website fotos'
		   },
		   function(response) {
		     if (response && response.post_id) {
		       //alert('Post was published.');
		     } else {
		       //alert('Post was not published.');
		     }
		   }
		 );
	}
	
	function shareImage(imgPath, descricao, pageURL){         
	    var attachment = {
					  'name' : 'GoNatural',
					  'href' : websiteURL+'#/'+pageURL,
					  'caption' : '{*actor*} gosta de Go Natural Website Fotos',
					  'description' : descricao,
					  'media' : [{'type' : 'image', 'src' : websiteURL+''+imgPath, 'href' : websiteURL+'#/'+pageURL}] //A imagem tem de estar online!
					  };
		var action_links = [{'text' : 'Saiba mais +','href' : websiteURL+'#/'+pageURL}];                         
		
		 FB.ui(
		   {
		     method: 'stream.publish',
		     attachment: attachment,
		     action_links: action_links,
		     user_prompt_message: '{*actor*} gosta de Go Natural website fotos'
		   },
		   function(response) {
		     if (response && response.post_id) {
		       //alert('Post was published.');
		     } else {
		       //alert('Post was not published.');
		     }
		   }
		 );
	}
	
	function shareVideo(idFilme){
		window.open("http://www.facebook.com/sharer.php?u=http://www.youtube.com/watch?v="+idFilme+"");
	}
/* FIM DE FACEBOOK */
