function login(id){	
	$.ajax({
		type: "POST",
		url: base_url+"/index.php/home/login/" + id,
		data: $("#login_form").serialize(),
		success: function(msg){
			//alert(msg)
			arr = msg.split("=");
			switch(arr[0]){
				case 'msg':
					$("#error_login").html(arr[1]);			
					break;
				case 'url':
					document.location.href=arr[1];
			}
		}
	});
}

function recupera_pass(){	
	$.ajax({
		type: "POST",
		url: base_url+"index.php/home/recupera_password/",
		data: $("#recupera_form").serialize(),
		success: function(msg){
			//alert(msg)
			arr = msg.split("=");
			switch(arr[0]){
				case 'msg':
					$("#error_recupera").html(arr[1]);			
					break;
				case 'ok':
					$("#error_recupera").html(arr[1]);
			}
		}
	});
}
/*function registration(){
	$.ajax({
		type: "POST",
		url: "http://demo.beeweb.it/facefood/index.php/home/new_attore",
		data: $("form").serialize(),
		success: function(msg){
			arr = msg.split("=");
			switch(arr[0]){
				case 'msg':
					$("#error_reg").html(arr[1]);			
					break;
				case 'succ':
					$("#container").html(arr[1]);
			}
		}
	});
}
*/

function cambia_password(tipo){
	$.ajax({
		type: "POST",
		url: base_url+tipo+".php/"+tipo+"/cambia_pswd",
		data: $("#password_form").serialize(),
		success: function(msg){
			arr = msg.split("=");
			switch(arr[0]){
				case 'msg':
					$("#error_reg").html(arr[1]);			
					break;
				case 'url':
					document.location.href=arr[1];
			}
		}
	});
}

function new_abbinamento(id, fb){
	$.ajax({
		type: "POST",
		url: base_url+"consumatore.php/consumatore/abbinamenti/"+id,
		data: $("#abbinamento_form").serialize(),
		success: function(msg){
			if(fb == 1)
				FB.Connect.streamPublish('', {'name':'FaceFood','href': base_url+'consumatore.php/consumatore/abbinamenti/' + id, 'description': $("#abbinamento").val()}, null, null, null, null, true);
			arr = msg.split("=");
			switch(arr[0]){
				case 'msg':
					$("#error_reg").html(arr[1]);			
					break;
				case 'url':
					document.location.href=arr[1];
			}
		}
	});
}

function new_commento(id, id_prod, fb){	
	$.ajax({
		type: "POST",
		url: base_url+"consumatore.php/consumatore/new_commento/"+id,
		data: $("#commento_form").serialize(),
		success: function(msg){
			if(fb == 1)
				FB.Connect.streamPublish('', {'name':'FaceFood','href': base_url+'consumatore.php/consumatore/abbinamenti/' + id_prod, 'description': $("#commento").val()}, null, null, null, null, true);
			arr = msg.split("=");
			switch(arr[0]){
				case 'msg':
					$("#error_reg").html(arr[1]);			
					break;
				case 'url':
					document.location.href=arr[1];
			}
		}
	});
}

function new_amico(id, tipo){
	$.ajax({
		type: "POST",
		url: base_url+tipo+".php/"+tipo+"/new_amico/"+id,
		data: $("#amico_form").serialize(),
		success: function(msg){
			arr = msg.split("=");
			switch(arr[0]){
				case 'msg':
					$("#error_reg").html(arr[1]);			
					break;
				case 'url':
					document.location.href=arr[1];
			}
		}
	});
}

function new_messaggio(tipo){	
	$.ajax({
		type: "POST",
		url: base_url+tipo+".php/"+tipo+"/nuovo_messaggio",
		data: $("#messaggio_form").serialize(),
		success: function(msg){
			arr = msg.split("=");
			switch(arr[0]){
				case 'msg':
					$("#error_reg").html(arr[1]);			
					break;
				case 'succ':
					$("#container").html(arr[1]);
			}
		}
	});
}

/*function in_home(){	
	$.ajax({
		type: "POST",
		url: "http://demo.beeweb.it/facefood/users.php/users/in_home",
		data: $("form").serialize(),
		success: function(msg){
			document.location.href="http://demo.beeweb.it/facefood/users.php";
		}
	});
}*/

function apri_chiudi_mappa(stato){
	$.ajax({
		type: "POST",
		url: base_url+"index.php/home/apri_chiudi_mappa/"+stato
	});
}
