﻿$(document).ready(function()
{
	$(".rge_img_hoverable").hover(home_imageHover,home_imageNormal);

	
	$("#DowloadLink").click(function()
	{
		alert("Bonjour, Merci d'avoir téléchargé mon logiciel.\nJe vous serais reconnaissant de votre soutient avec une petit clic sur la pub.");
	});
	
	$("a[id^='facebook_share_button']").attr("href","#").click(shareOnFacebook);
	
	FB.init("ccb8a5c7c1bff4a387cd8be941f29994");
});

function home_imageHover()
{
	src = $(this).attr("src");
	if(src.lastIndexOf("_hover.png") == -1)
		src = src.replace(".png","_hover.png");
	$(this).attr("src",src);
}
function home_imageNormal()
{
	src = $(this).attr("src");
	if(src.lastIndexOf("_hover.png") > -1)
		src = src.replace("_hover.png",".png");
	$(this).attr("src",src);
}

document.write('<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/fr_FR" type="text/javascript"></script>');
function callPublish(msg, attachment, action_link) 
{
  FB.ensureInit(function () {
    FB.Connect.streamPublish('', attachment, action_link);
  });
}
function shareOnFacebook()
{
	var fbContent = $("#text_for_facebook").html().split("<br>");
	var img = "http://renaudgerson.fr/StarterBackgroundChanger/wp-content/uploads/2009/12/a_quoi_sert_il.png";
	if($("link[rel='image_src']").length>0)
		img = $("link[rel='image_src']").eq(0).attr("href");
	callPublish('',{'name':fbContent[0],'href':'http://renaudgerson.fr/StarterBackgroundChanger/','description':fbContent[1],'media':[{'type':'image','src':img,'href':'http://renaudgerson.fr/StarterBackgroundChanger/'}]},null);
	return false;
}
