﻿/* REDES */
function onFacebook() {
	var _link = "http://www.mukuralab.com/diletto/contenido.php";
	_link = encodeURIComponent(_link);
	var _title = "Diletto Café te invita a compartir su espacio orignal en Internet";
	_title = encodeURIComponent(_title);
	var url = "http://www.facebook.com/sharer.php?u=" + _link + "&t=" + _title;
	//url = "index.php";
	//alert(url);
	//$('#facebook').colorbox({iframe: true, innerWidth:570, innerHeight:304});
	//window.open(url, "facebook", "location=1,status=1,height=304,width=570");
	postComment();
}

	/* facebook */
	FB.init("dc71ba2731f34ac7b901739a081dc517","xd_receiver.htm", {});

	function update_user_box()
	{
		var user_box = document.getElementById("user"); // add in some XFBML. note that we set useyou=false so it doesn't display "you"
		user_box.innerHTML = "<span>" + "<fb:profile-pic uid='loggedinuser' facebook-logo='true'></fb:profile-pic>" + "Welcome, <fb:name uid='loggedinuser' useyou='false'></fb:name>. You are signed in with your Facebook account." + "</span>"; // because this is XFBML, we need to tell Facebook to re-process the document
		FB.XFBML.Host.parseDomTree();
	} 

	function postComment()
	{
		FB.Connect.ifUserConnected(connectedFB, noConnectedFB);
	}
	
	function connectedFB(user_id)
	{
		_postComment();
	}
	
	function noConnectedFB()
	{
		FB.Connect.requireSession(_postComment, function(){/*alert("requireSesionCallbackCancel");*/}, true);
	}
	
	function _postComment()
	{
		//imagen: http://bit.ly/cFPNcw   -- http://www.mukuralab.com/diletto/images/espresso.jpg
		//sitio: http://bit.ly/ceft3f  -- http://www.mukuralab.com/diletto/contenido.php
		//alert("requireSesionCallback");
		var attachment = {'media': [{'type':'image',
								 'src':'http://bit.ly/cFPNcw',
								 'href':'http://bit.ly/ceft3f'}]};
	
		var attachment = { 'name': 'Diletto', 'href': 'http://bit.ly/ceft3f', 'caption': '{*actor*} está conectado con Diletto', 'description': 'Diletto Café te invita a compartir su espacio orignal en Internet.', 'media': [{ 'type': 'image', 'src': 'http://bit.ly/cFPNcw', 'href': 'http://bit.ly/ceft3f'}] }; var action_links = [{'text':'Conoce más', 'href':'http://bit.ly/ceft3f'}]; 

		FB.Connect.streamPublish('', attachment, action_links, null, 'Diletto Café', stream_callback);
	}
	
	function stream_callback (post_id, exception) {
		if (post_id) {
			//	alert(post_id);
		}
	}