function showPath(menu_pere_id, menu_id) {
	$.post("path.php", { menu_pere_id : menu_pere_id, menu_id: menu_id },
			function(data){
				$("#div_path").html(data);
			}
		);
}

function showArticle(article_id, critere) {
	if (critere == null)
		critere = "";
	$.post("article.php", { article_id: article_id, critere:critere },
			function(data){
				$("#div_article").html(data).slideDown("slow");
			}
		);
}

function showCorpsArticle(menu_pere_id, menu_id, article_id, critere) {
	var hash;
	hash = "article," + menu_pere_id + "," + menu_id + "," + article_id + ",";
	if (typeof(critere) != 'undefined')
		hash += critere;
	hash = hash.replace(/^.*#/, '');
	$.historyLoad(hash);
}

function getFacebookUrl(article_id) {
	var url;
	url = "" + document.location;
	if (url.indexOf("?article=") < 0)
		url = url.replace("#", "?article=" + article_id + "#");
	return url;
	alert(encodeURIComponent(url));
}

function partagerFacebook(article_id) {
	var leftVal;
	var topVal;
	leftVal = (screen.width - 626) / 2;
	topVal = (screen.height - 436) / 2;
	window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(getFacebookUrl(article_id)), 'sharer', 'toolbar=0,status=0,resizable=1,width=626,height=436,left=' + leftVal + ',top=' + topVal);
}

function partagerMySpace() {
	//$("#myspacepostto_u").val(document.location);
	var linkToArticle;
	linkToArticle = "<a href='" + document.location + "'>Lire l'article...</a>"
	$("#myspacepostto_c").val($("#myspacepostto_c_temp").val() + linkToArticle);
	pop_it('myspacepostto');
	//document.getElementById('myspacepostto').submit();
}

function pop_it(the_form) {
	my_form = document.getElementById(the_form);
	var leftVal;
	var topVal;
	leftVal = (screen.width - 840) / 2;
	topVal = (screen.height - 750) / 2;
	mywindow = window.open("", "popup", 'toolbar=0,status=0,resizable=1,width=840,height=750,left=' + leftVal + ',top=' + topVal);
	my_form.target = "popup";
	my_form.submit();
}

function showCorpsArticleHisto(menu_pere_id, menu_id, article_id, critere) {
	gotoCenter();
	$.post("corps_article.php", { menu_pere_id : menu_pere_id, menu_id: menu_id, article_id: article_id },
			function(data){
				$("#div_column_center").slideUp("slow", function () {
					$("#div_column_center").html(data).slideDown("slow", function() {
						showMenu(menu_pere_id);
						showPath(menu_pere_id, menu_id);
						showArticle(article_id, critere);
						showArticlesChoisis();
					});
				});
			}
		);
}

function showArticles(menu_pere_id, menu_id, page) {
	var hash;
	hash = "articles," + menu_pere_id + "," + menu_id + ",";
	if (typeof(page) != 'undefined')
		hash += page;
	hash = hash.replace(/^.*#/, '');
	$.historyLoad(hash);
}

function showArticlesHisto(menu_pere_id, menu_id, page) {
	gotoCenter();
	$.post("corps_articles.php", { menu_pere_id : menu_pere_id, menu_id: menu_id, page: page },
			function(data){
				$("#div_column_center").slideUp("slow", function () {
					$("#div_column_center").html(data).slideDown("slow", function () {
						showMenu(menu_pere_id);
						showPath(menu_pere_id, menu_id);
						showListeArticlesHisto(menu_pere_id, menu_id, page);
						showArticlesChoisis();
					});
				});
			}
		);
}

function showListeArticles(menu_pere_id, menu_id, page) {
	var hash;
	hash = "lstarticles," + menu_pere_id + "," + menu_id + ",";
	if (typeof(page) != 'undefined')
		hash += page;
	hash = hash.replace(/^.*#/, '');
	$.historyLoad(hash);
}

function showListeArticlesHisto(menu_pere_id, menu_id, page) {
	gotoCenter();
	$.post("article.list.php", { menu_pere_id : menu_pere_id, menu_id: menu_id, page: page },
		function(data){
			$("#div_articles").slideUp("slow", function () {
				$("#div_articles").html(data).slideDown("slow");
			});
		}
	);
}

function showArticlesChoisis() {
	$.post("article_choisi.php", { },
		function(data){
			$("#div_column_right_1").slideUp("slow", function () {
				$("#div_column_right_1").html(data).slideDown("slow");
			});
		}
	);
}