function add_favoris(noSerie,noProduit){
	if(document.getElementById("fav_img").src.indexOf("icone_heart.png") > 0){
		remove_favoris(noSerie,noProduit);	
	} else {
		if(noSerie != ""){
			//alert("on ajoute une série");
			$.ajax({
					type: 'POST',
					url: 'includes/favoris_upd.asp',
					data: {flag:"add_favoris", noSerie:noSerie, noProduit:""},
					dataType: 'html',
					success: function(html, textStatus){
						//alert(html);
						document.getElementById("plus_minus1").innerHTML = '-'; //document.getElementById("plus_minus1").innerHTML.replace("+","-");
						document.getElementById("fav_img").src = "./images/icone_heart.png";
						cpt_favoris();
					},
					error: function(xhr, textStatus, errorThrown){
						alert(xhr.responseText);
						alert('An error occurred! ' + (errorThrown ? errorThrown : xhr.status));
					}
				});
		} else {
			//alert("on ajoute un produit");
			$.ajax({
					type: 'POST',
					url: 'includes/favoris_upd.asp',
					data: {flag:"add_favoris", noSerie:noSerie, noProduit:noProduit},
					dataType: 'html',
					success: function(html, textStatus){
						//alert(html)
						document.getElementById("plus_minus1").innerHTML = '-'; //document.getElementById("plus_minus1").innerHTML.replace("+","-");
						document.getElementById("fav_img").src = "./images/icone_heart.png";
						cpt_favoris();
					},
					error: function(xhr, textStatus, errorThrown){
						alert(xhr.responseText);
						alert('An error occurred! ' + (errorThrown ? errorThrown : xhr.status));
					}
				});
		}
	}
}

function remove_favoris(noSerie,noProduit){
	
	/*if(document.getElementById("plus_minus").innerHTML == "+"){
		add_favoris(noSerie,noProduit);
	}*/
	
	if(noSerie != ""){
		//alert("on ajoute une série");
		$.ajax({
				type: 'POST',
				url: 'includes/favoris_upd.asp',
				data: {flag:"remove_favoris", noSerie:noSerie, noProduit:""},
				dataType: 'html',
				success: function(html, textStatus){
				//	alert(html);
					document.getElementById("plus_minus1").innerHTML = '+'; //document.getElementById("plus_minus1").innerHTML.replace("-","+");
					document.getElementById("fav_img").src = "./images/icone_fav_rc.png";
					cpt_favoris();
				},
				error: function(xhr, textStatus, errorThrown){
					alert(xhr.responseText);
					alert('An error occurred! ' + (errorThrown ? errorThrown : xhr.status));
				}
			});
	} else {
		//alert("on ajoute un produit");
		$.ajax({
				type: 'POST',
				url: 'includes/favoris_upd.asp',
				data: {flag:"remove_favoris", noSerie:noSerie, noProduit:noProduit},
				dataType: 'html',
				success: function(html, textStatus){
					//alert(html)
					document.getElementById("plus_minus1").innerHTML = '+'; //document.getElementById("plus_minus1").innerHTML.replace("-","+");
					document.getElementById("fav_img").src = "./images/icone_fav_rc.png";
					cpt_favoris();
				},
				error: function(xhr, textStatus, errorThrown){
					alert(xhr.responseText);
					alert('An error occurred! ' + (errorThrown ? errorThrown : xhr.status));
				}
			});
	}
}



function cpt_favoris(){
	//alert("on ajoute un produit");
		$.ajax({
				type: 'POST',
				url: 'includes/favoris_upd.asp',
				data: {flag:"count_fav_items"},
				dataType: 'html',
				success: function(html, textStatus){
					if(html == "1" || html == "0"){
						mot_item = "item";
					} else {
						mot_item = "items";	
					}
					document.getElementById('fav_nbr_items').innerHTML = "(" + html + " " + mot_item + ")"; 
					////alert(html)
				},
				error: function(xhr, textStatus, errorThrown){
					alert(xhr.responseText);
					alert('An error occurred! ' + (errorThrown ? errorThrown : xhr.status));
				}
			});
}
