// JavaScript Document
function showMediaSlide(media) {
	$.post("media.slide.php", { media: media },
			function(data){
				 $("#div_media_slide_group").html(data);
			}
		);
}

function selMediathequeMenu(obj) {
	$("#div_media_menus li").removeClass("sel");
	if (!obj.hasClass("sel")) {
		obj.addClass("sel");
	}
}

function showMediatheque(menu_id) {
	var hash;
	hash = "mediatheque," + menu_id;
	hash = hash.replace(/^.*#/, '');
	$.historyLoad(hash);
}

function showMediathequeHisto(menu_id) {
	gotoCenter();
	$.post("mediatheque.corps.php", { menu_id : menu_id },
			function(data){
				$("#div_column_center").slideUp("slow", function () {
					$("#div_column_center").html(data).slideDown("slow");
					hideSagesse();
					showMediathequeMenu(menu_id);
				});
			}
		);
}

function showMediathequeMenu(menu_id) {
	var hash;
	hash = "mediathequemenu," + menu_id;
	hash = hash.replace(/^.*#/, '');
	$.historyLoad(hash);
}

function showMediathequeMenuHisto(menu_id) {
	$.post("mediatheque.menu.php", { menu_id : menu_id },
			function(data){
					$("#div_mediatheque_menu").html(data).slideDown("slow");
			}
		);
}

function showMediathequeCategorie(menu_id) {
	$.post("mediatheque.categorie.php", { menu_id : menu_id },
			function(data){
					$("#div_big_media_categorie").html(data).slideDown("slow");
			}
		);
}

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

function setCategorie(categorie_id) {
	$("#media_categorie").val(categorie_id);
	//$("#media_categorie").selectOptions(categorie_id);
}

function showMediathequeMediaHisto(menu_id, categorie_id, page) {
	setCategorie(categorie_id);
	$.post("mediatheque.php", { menu_id : menu_id, categorie_id : categorie_id, page : page },
			function(data){
				$("#div_mediatheque_media").slideUp("slow", function () {
					$("#div_mediatheque_media").html(data).slideDown("slow");
				});
			}
		);
}

function showMedia(media, article_id, auto_play) {
	if (media == 'audio') {
		showAudio(article_id, auto_play);
	} else if (media == 'video') {
		showVideo(article_id, auto_play);
	} else if (media == 'photo') {
		showPhoto(article_id);
	}
	
}

function showAudio(article_id, auto_play) {
	$.post("player.audio.php", { article_id: article_id, auto_play: auto_play },
			function(data){
				 $("#div_media_player").html(data);
			}
		);
}

function showVideo(article_id, auto_play) {
	$.post("player.iframe.php", { article_id: article_id, auto_play: auto_play },
			function(data){
				 $("#div_media_player").html(data);
			}
		);
}

function showPhoto(article_id) {
	$.post("player.photo.php", { article_id: article_id },
			function(data){
				 $("#div_media_player").html(data);
			}
		);
}

function gotoMedia() {
	pos = $("#div_column_right_2").findPos();
	$.scrollTo( pos.y - 10, 800, {queue:true} );
}

function showVideoFromArticle(article_id) {
	gotoMedia();
	showMedia('video', article_id, 1);
}