function increment_qte(input_id){
	document.getElementById(input_id).value = parseInt(document.getElementById(input_id).value) + 1 ;
}
function decrement_qte(input_id){
	if (document.getElementById(input_id).value > 1){
	document.getElementById(input_id).value = parseInt(document.getElementById(input_id).value) - 1 ;
	}else{
	alert("Attention, la quantité commandée doit au minimum être égale à 1")
	}
}
function add_prod_to_basket(pid,urlsite,seul,act,obid){
	input_id = "input_"+pid;
	qte=document.getElementById(input_id).value;
	
	if (act==undefined){
	act='';
	}	
	if (seul==undefined){
	seul='vide';
	}
	if (obid==undefined){
	obid='';
	}
	
	
	if(act == 'change'){
		agent.call('','add_prod_to_basket','add_prod_to_basket_return2',pid,qte,urlsite,seul,act,obid);
	}else{
		agent.call('','add_prod_to_basket','add_prod_to_basket_return',pid,qte,urlsite,seul);
	}

	a = setTimeout('reload_basket("'+urlsite+'");',1000);

}
function add_prod_to_basket_return(str){
	
	//document.getElementById("basket_content").innerHTML = str;
}
function add_prod_to_basket_return2(str){
	document.location.href = str;
}
function remove_product_from_basket(basket_id,url_site){
	if (confirm('Etes vous sûr de vouloir supprimer ce produit?')){
	agent.call('', 'remove_product_from_basket', 'remove_product_from_basket_return', basket_id, url_site);
	}	
}
function remove_product_from_basket_return(str){
	document.getElementById("basket_content").innerHTML = str;
}

function charger_infos_menu(pid, urlsite, cat){
	agent.call('','charger_infos_menu','charger_infos_menu_return',pid, urlsite, cat);
}

function charger_infos_menu_return(str){
	tableau = str.split(";");
	cat = tableau [2];
	
	document.getElementById('produit_description' + cat).innerHTML = tableau [0];
	document.getElementById('produit_img' + cat).innerHTML = tableau [1];
}

function add_sub_prods_to_basket(pid,qte,urlsite,act,bid)
{
	//add_qte = top.window.document.getElementById('input_'+pid).value;
	add_qte = 1;
	
	//ajout du produits "mere" (menu)
	if (act==undefined)
	{
		act='';
	}
	if (bid==undefined)
	{
		bid='';
	}
	
	if(act == 'change')
	{
		agent.call('','add_prod_to_basket','',pid,add_qte,urlsite,false,act,bid);
	}
	else
	{
		agent.call('','add_prod_to_basket','',pid,add_qte,urlsite,false);
	}
	
	//traitement des sous produits
	for (i=0; i<qte; i++)
	{	
		liste_id = 'products_list_' + i;
		subpid = document.getElementById(liste_id).value;
		agent.call('','add_sub_prods_to_basket','',pid, subpid, add_qte);
	}
		
	reload_basket(urlsite);
		
}

function reload_basket(urlsite){
	if (urlsite==undefined){
	urlsite='';
	}	
	agent.call('','reload_basket','reload_basket_return', urlsite);
}

function reload_basket_return(str){
	top.window.document.getElementById('basket_content').innerHTML = str;
}

function compose_menu(pid,url,act,bid, title){

	ext = "";
	if (act!="" && bid != ""){
	ext = "&act=" + act + "&bid=" + bid;
	}
	
	GB_showCenter(title,  url+"inc/gestion-menus.php?pid="+pid + ext,400,600);
	}
function appel_related_prod(pid){
	agent.call('','appel_related_prod','appel_related_prod_return',pid,1,'',0,0,0);
	}
	
function appel_related_prod_return(str){
	GB_showCenter(str,  url+"inc/gestion-menus.php?pid="+pid,400,300);
	}
