var timerReseau = "";

function addSelection(id_fr,noreload,page,aff){

	var href = location.href;

	if(!aff){  aff = 1; }
	if(!page){ page = ""; }
		
    $.get('/selection.php?actionSel=add&id='+id_fr,function(data){
		if(!noreload)
			if(data==true){ aj=1; }else{ aj=0; }
				
				if(document.getElementById("selection")){
					$('#selection').load('/selection.php?href='+href, function() {
					  // $('div.pane').scrollTo(0, 100, {easing:'swing'});
					});$
				}
			
			if(aff==1){
				afficheModal('','/modal_ajout_selection.php?id='+id_fr+'&aj='+aj,'702','288','','',false);
			}
    });
}

function Timer(){
	$('span.newRezo').slideUp(950);
	window.clearTimeout(timerReseau);
}

function delAllSelection(page){

	var href = location.href;

	if(!page){ page = ""; }
	$.get('/selection.php?actionSel=delall',function(){
		if(page==""){
			if(document.getElementById("selection")){
				$('#selection').load('/selection.php?href='+href);
			}
		}else{
			if(document.getElementById("selection")){
				$('#selection').load('/selection2.php');
			}
		}
    });
}

function delSelection(id_fr,page){

	var href = location.href;

	if(!page){ page = ""; }
    $.get('/selection.php?actionSel=del&id='+id_fr,function(){
		if(page==""){
			if(document.getElementById("selection")){
				$('#selection').load('/selection.php?href='+href);
			}
		}else{
			if(document.getElementById("selection")){
				$('#selection').load('/selection2.php');
			}
		} 
    });
}

function fermeFicheDetaillee(id_fr){ $('#ficheDetaillee' + id_fr).hide(); }

function loadFicheDetaillee(id_fr){ $('#ficheDetaillee' + id_fr).load('ajax_fiche_detaillee.php?id=' + id_fr); }

$(document).ready(function() {
	currentLocation =  document.location.href;
	$('#selection').load('/selection.php?href='+currentLocation);
});

function triSelectReseau(name){
	var sec = document.getElementById("triActSel").value;
	if(document.getElementById("triAppSel")){
		var app = document.getElementById("triAppSel").value;
	}else{ var app=""; }
	
	$.ajax({
		url: 'triReseau.php?sec='+sec+'&app='+app+'&name='+name,
		dataType: "html",
		success: function(html){
			$('#triReseau').html(html);
			if(name=="sec"){
				$.ajax({
					url: 'triSelApp.php?sec='+sec,
					dataType: "html",
					success: function(html){
						$('#triApp').html(html);
					}
				});
			}
		}
	});
}
