function ajax_charge_applications(licence_id)
{	
$.ajax({
   type: "POST",
   url: "./actionsAjax.php",
   data: "action=getListApp&licence_name="+$("#nom_licence_input").val()+"&licence_id="+licence_id,
   dataType:"html",
   error:function(msg){
     alert( "Error !: " + msg );
   },
   success:function(data){
	$('#contenu_fichier_ajax_ajout').html(data);
}});
}

function ajax_recharge_applications(licence)
{	
$.ajax({
   type: "POST",
   url: "./actionsAjax.php",
   data: "action=getListApp_iPuP&licence="+licence,
   dataType:"html",
   error:function(msg){
     alert( "Error !: " + msg );
   },
   success:function(data){
		$('#contenu_fichier_ajax').html(data);
}});
}

function ajax_saveapp(app, licence_id)
{	
$.ajax({
   type: "POST",
   url: "./actionsAjax.php",
   data: "action=saveApp&App="+app+"&Licence="+licence_id,
   dataType:"html",
   error:function(msg){
     alert( "Error !: " + msg );
   },
   success:function(data){
	 //alert(data);
	 ajax_charge_applications(licence_id);
	 ajax_recharge_applications(licence_id);	 
}});
}

function getSelectValue(selectId)
{
	/**On récupère l'élement html <select>*/
	var selectElmnt = document.getElementById(selectId);
	/**
	selectElmt.options correspond au tableau des balises <option> du select
	selectElmt.selectedIndex correspond à l'index du tableau options qui est actuellement sélectionné
	*/
	return selectElmt.options[selectElmt.selectedIndex].value;
}

function deletAPp(appId)
{
	
	if (confirm('supprimer cette application'))
	{
		$.ajax({
	   type: "POST",
	   url: "./actionsAjax.php",
	   data: "action=deletApp&App="+appId,
	   dataType:"html",
	   error:function(msg){
	     alert( "Error !: " + msg );
	   },
	   success:function(data){
		ajax_recharge_applications(data);
	 	ajax_charge_applications(data);
	}});
	}
}

function deletLicence(licence_id)
{
	if (confirm('supprimer cette licence'))
	{
		$.ajax({
	   type: "POST",
	   url: "./actionsAjax.php",
	   data: "action=deleteLicence&Licence="+licence_id,
	   dataType:"html",
	   error:function(msg){
	     alert( "Error !: " + msg );
	   },
	   success:function(data){
	   //alert(data);
	   document.location.href="mesLicences";
	}});
	}
}

function afficher_formulaire_licence()
{
$.ajax({
   type: "POST",
   url: "./actionsAjax.php",
   data: "action=afficher_formulaire_licence",
   dataType:"html",
   error:function(msg){
     alert( "Error !: " + msg );
   },
   success:function(data){
	$('#espace_formulaire_licence').html(data);
}});
}

function formulaire_edition_licence(id_licence)
{
$.ajax({
   type: "POST",
   url: "./actionsAjax.php",
   data: "action=formulaire_edition_licence&id_licence="+id_licence,
   dataType:"html",
   error:function(msg){
     alert( "Error !: " + msg );
   },
   success:function(data){
	$('#espace_formulaire_licence').html(data);
}});
}


function vote(id_app)
{
$.ajax({
   type: "POST",
   url: "./actionsAjax.php",
   data: "action=vote&id_app="+id_app,
   dataType:"html",
   error:function(msg){
     alert( "Error !: " + msg );
   },
   success:function(data){
	alert(data);
}});
}

function app_payantes_suivante(page_courante, nb_page)
{
$.ajax({
   type: "POST",
   url: "./actionsAjax.php",
   data: "action=app_payantes_suivante&page_courante="+page_courante+"&nb_page="+nb_page,
   dataType:"html",
   error:function(msg){
     alert( "Error !: " + msg );
   },
   success:function(data){
	$('#Bloc_App4').html(data);
}});
}

function app_payantes_precedente(page_courante, nb_page)
{
$.ajax({
   type: "POST",
   url: "./actionsAjax.php",
   data: "action=app_payantes_precedente&page_courante="+page_courante+"&nb_page="+nb_page,
   dataType:"html",
   error:function(msg){
     alert( "Error !: " + msg );
   },
   success:function(data){
	$('#Bloc_App4').html(data);
}});
}

function app_top_suivante(page_courante, nb_page)
{
$.ajax({
   type: "POST",
   url: "./actionsAjax.php",
   data: "action=app_top_suivante&page_courante="+page_courante+"&nb_page="+nb_page,
   dataType:"html",
   error:function(msg){
     alert( "Error !: " + msg );
   },
   success:function(data){
	$('#Bloc_App3').html(data);
}});
}

function app_top_precedente(page_courante, nb_page)
{
$.ajax({
   type: "POST",
   url: "./actionsAjax.php",
   data: "action=app_top_precedente&page_courante="+page_courante+"&nb_page="+nb_page,
   dataType:"html",
   error:function(msg){
     alert( "Error !: " + msg );
   },
   success:function(data){
	$('#Bloc_App3').html(data);
}});
}

function app_gratuites_suivante(page_courante, nb_page)
{
$.ajax({
   type: "POST",
   url: "./actionsAjax.php",
   data: "action=app_gratuites_suivante&page_courante="+page_courante+"&nb_page="+nb_page,
   dataType:"html",
   error:function(msg){
     alert( "Error !: " + msg );
   },
   success:function(data){
	$('#Bloc_App2').html(data);
}});
}

function app_gratuites_precedente(page_courante, nb_page)
{
$.ajax({
   type: "POST",
   url: "./actionsAjax.php",
   data: "action=app_gratuites_precedente&page_courante="+page_courante+"&nb_page="+nb_page,
   dataType:"html",
   error:function(msg){
     alert( "Error !: " + msg );
   },
   success:function(data){
	$('#Bloc_App2').html(data);
}});
}

function edit_selection_dev(licence)
{
$.ajax({
   type: "POST",
   url: "./actionsAjax.php",
   data: "action=edit_selection_dev&licence="+licence,
   dataType:"html",
   error:function(msg){
     alert( "Error !: " + msg );
   },
   success:function(data){
	if(data == 1){
		$('#bouton_mise_avant_dev').val('ne plus mettre en avant');
	}
	else{
		$('#bouton_mise_avant_dev').val('mettre en avant');
	}
}});
}

function edit_selection_app(id_app)
{
var emplacement = $('#app_'+id_app).val();
$.ajax({
   type: "POST",
   url: "./actionsAjax.php",
   data: "action=edit_selection_app&id_app="+id_app+'&emplacement='+emplacement,
   dataType:"html",
   error:function(msg){
     alert( "Error !: " + msg );
   },
   success:function(data){
}});
}

function dev_catalogue_suivant(page_courante, nb_page)
{
$.ajax({
   type: "POST",
   url: "./actionsAjax.php",
   data: "action=dev_catalogue_suivant&page_courante="+page_courante+"&nb_page="+nb_page,
   dataType:"html",
   error:function(msg){
     alert( "Error !: " + msg );
   },
   success:function(data){
	$('#Bloc_App_Developpeur').html(data);
}});
}

function dev_catalogue_precedent(page_courante, nb_page)
{
$.ajax({
   type: "POST",
   url: "./actionsAjax.php",
   data: "action=dev_catalogue_precedent&page_courante="+page_courante+"&nb_page="+nb_page,
   dataType:"html",
   error:function(msg){
     alert( "Error !: " + msg );
   },
   success:function(data){
	$('#Bloc_App_Developpeur').html(data);
}});
}