var FB = {
	url : "http://www.facebook.com/sharer.php",
	u : document.location // Location to share
};

var TWIT = {
		url : "http://twitter.com/home"
};


function getShortUrls(){
	var activeUri=escape(document.location);
}
function getItUri(data){
	//alert('Facebook');
	var activeUri=escape(document.location);
	getIt = activeUri;
	
	var getUrl=FB.url + "?u=";
	var statusUri=TWIT.url + "?status=" + jQuery("title").html() + " : ";
	
	jQuery("#breadCrumb #social").html(addFB(getIt,getUrl) + " " + addTwit(getIt,statusUri));
}


function addFB(getIt,getUrl){
	var titleFB = "&t=" + jQuery("title").html();

	var htmlIt = "<a href='"+getUrl+getIt+"' id='fbLink' target='_blank'><img src='assets/fb.jpg' alt='Partagez cette page sur mon profil' /></a>";
	return htmlIt;
		
}

function addTwit(getIt,statusUri){
	
	var htmlIt = "<a href='"+statusUri+getIt+"' id='twitLink' target='_blank'><img src='assets/twitter.jpg' alt='Partagez cette page sur Twitter' /></a>";
	return htmlIt;
		
}

function detectRecom(){
	var RecomLoc = jQuery("body #container #content .recommend");
	return RecomLoc;
}

function rewriteRecom(){
	var source = "http://www.facebook.com/plugins/like.php?href="+document.location+"&layout=standard&show_faces=true&width=450&action=recommend&font=verdana&locale=fr_FR&colorscheme=light&height=80";
	jQuery(".recommend").attr("src",source);
}


jQuery(document).ready(function(){
	
	getShortUrls();
	
	if(detectRecom()) {rewriteRecom();}
	
	jQuery("#fbLink").click(function(){
		window.open(FB.url + "?u=" + FB.u + "&t=" + jQuery("title").html(),"fbwin","menubar=0,resizable=1,status=1,scrollbars=1,width=795,height=635");
		return false;
	});
	jQuery("#twitLink").click(function(){
		window.open(TWIT.url + "?status=" + jQuery("title").html() + " : " + document.location,"twitwin","menubar=0,resizable=1,status=1,scrollbars=1,width=795,height=635");
		return false;
	});
	
});
