// JavaScript Document

$(document).ready(function () {

	getIndex();

	$('#check1').click(function(e) {
		if(check1 && check2) {
			$("#imgCheck1").attr('src', 'images/chekboxOff.png');
			check1 = 0;
			getIndex();
		} else {
			$("#imgCheck1").attr('src', 'images/chekboxOn.png');
			check1 = 1;
			getIndex();
		}
	});
	$('#check2').click(function(e) {
		if(check1 && check2) {
			$("#imgCheck2").attr('src', 'images/chekboxOff.png');
			check2 = 0;
			getIndex();
		} else {
			$("#imgCheck2").attr('src', 'images/chekboxOn.png');
			check2 = 1;
			getIndex();
		}
	});

});

function getIndex() {
	var i=1;
	var lstCat = '';
	if(check1){
		lstCat = 'cat'+i+'='+tabCat[i-1];
	}
	i++;
	if(check2) {
		if(lstCat != '') {
			lstCat += '&';
		}
		lstCat += 'cat'+i+'='+tabCat[i-1];
	}
	$.ajax({
		type: 'GET',
		url: 'ajax/afficheIndex.php?tc='+Number(new Date()),
		data: lstCat,
		success: function(msg){
			$('#cadreIndexData').html(msg);
			printCapsAlpha(bk_premLettreClasseur);
		}
	});
}

function printCapsAlpha(ini) {
	var i=1;
	var lstCat = '';
	if(check1 || ini == 'all') {
		lstCat = 'cat'+i+'='+tabCat[i-1];
	}
	i++;
	if(check2 || ini == 'all') {
		if(lstCat != '') {
			lstCat += '&';
		}
		lstCat += 'cat'+i+'='+tabCat[i-1];
	}
	$.ajax({
		type: "GET",
		url: "ajax/afficheCapsAlpha.php",
		data: 'ini='+ini+'&'+lstCat,
		success: function(msg){
			$('#listeCapsAlpha').html(msg);
		}
	});
}
