function fbuser_guard_rem(r){
	$.ajax({
	  url: "fbuserguard_rem.php",
	  type: "GET",
	  data: { r : r },
	  cache: false,
	  success: function(html){
	  	
		$("#fbuser_actiondiv").fadeOut();
		$("#fbuser_actiondiv").html("");
		fbuser_guard_updatelist();
	  }
	});	
}


function fbuser_inneboende(){
	$("#fbuser_actiondiv").load("fbuserinneboende.php?id=163").fadeIn();
}

function fbuserprofile_update (){



	$.ajax({
	  url: "fbuserprofile_update.php",
	  type: "GET",
	  data: { 
	  
	  	name 		: $("#fbuserprofile_name").val(),
		lan 		: $("#fbuserprofile_lan_ID").val(),
		district 	: $("#fbuserprofile_omrade_id").val(),
		zip 		: $("#fbuserprofile_zipcode").val(),
		gender 		: $("#fbuserprofile_gender").val(),
		email 		: $("#fbuserprofile_email").val(),
		birthday	: $("#fbuserprofile_birthday").val() ,
		birthmonth	: $("#fbuserprofile_birthmonth").val() ,
		birthyear	: $("#fbuserprofile_birthyear").val() 
		
	  },
	  cache: false,
	  success: function(html){

	  	$("#fbuserprofile_update_msg").html("Dina inställningar har sparats!");
		$("#fbuserprofile_update_msg").fadeOut(5000);


	  }
	});	

}

function fbuser_guard_onlywithphoto(id, bool, page){

	$.ajax({
	  url: "fbuserguard_onlywithphoto.php",
	  type: "GET",
	  data: { id : id, bool : bool },
	  cache: false,
	  success: function(html){

		fbuser_guard(id, page, true);
		fbuser_guard_updatelist();
	  }
	});	

}

function fbuser_guard_onlynew(id, bool, page){
	
	$.ajax({
	  url: "fbuserguard_onlynew.php",
	  type: "GET",
	  data: { id : id, bool : bool },
	  cache: false,
	  success: function(html){

		fbuser_guard(id, page, true);
		fbuser_guard_updatelist();
	  }
	});	
	
	
}


function fbuser_guard_remcat(id, cat, page){
	
	$.ajax({
	  url: "fbuserguard_remcat.php",
	  type: "GET",
	  data: { id : id, cat : cat },
	  cache: false,
	  success: function(html){
		fbuser_guard(id, page, true);
		fbuser_guard_updatelist();
	  }
	});	
	
	
}

function fbuser_guard_remtype(id, type, page){
	
	$.ajax({
	  url: "fbuserguard_remtype.php",
	  type: "GET",
	  data: { id : id, type : type },
	  cache: false,
	  success: function(html){
		fbuser_guard(id, page, true);
		fbuser_guard_updatelist();
	  }
	});	
	
	
}


function fbuser_guard_remdistrict(id, district, page){
	
	$.ajax({
	  url: "fbuserguard_remdistrict.php",
	  type: "GET",
	  data: { id : id, dist : district },
	  cache: false,
	  success: function(html){
	  	
	
		fbuser_guard(id, page, true);
		fbuser_guard_updatelist();
	  }
	});	
	
	
}

function fbuser_guard_updatelist(){

	AjaxGet("fbuserguard_list.php", { }, "fbuserbox_bevakningar");

}

var fbuserfav_open = false;
var fbuserguard_open = false;

function fbuser_favorites(page, forceopen)
{
	if(forceopen === true) fbuserfav_open = false;

	fbuserguard_open = false;

	if(fbuserfav_open){
		$("#fbuser_actiondiv").fadeOut();
		fbuserfav_open = false;
	} else {
		$("#fbuser_actiondiv").load("fbuserfav.php?page="+page).fadeIn();
		fbuserfav_open = true;
	}

	
}

function fbuser_guard(id, page, forceopen){

	if(forceopen === true) fbuserguard_open = false;
		
	fbuserfav_open = false;
		if(fbuserguard_open){
			$("#fbuser_actiondiv").fadeOut();
			fbuserguard_open = false;
		} else {
			$("#fbuser_actiondiv").load("fbuserguard.php?id="+id+"&page="+page).fadeIn();
			fbuserguard_open = true;
		}
	
	
}
function fbuserguard_addfav(id){

	$.ajax({
	  url: "fbuserfav_add.php",
	  type: "GET",
	  data: { id : id },
	  cache: false,
	  success: function(html){
	  	
		$("#fbuserguard_addfavlinkdiv_"+id).html("Sparad!");
		
		
	  }
	});	
}

function fbuser_bevakning(minhyra, maxhyra,minyta,maxyta,minpris,maxpris,minrum,maxrum,lan, omraden, typer, kategorier){
	


	$.ajax({
	  url: "fbuser_bevakning.php",
	  type: "GET",
	  data: {
		minhyra : minhyra,
		maxhyra : maxhyra,
		minyta : minyta,
		maxyta : maxyta,
		minpris : minpris,
		maxpris : maxpris,
		minrum : minrum,
		maxrum : maxrum,
		lan : lan,
		omraden : omraden,
		typer : typer,
		kategorier : kategorier 
	},
	  cache: false,
	  success: function(html){
	  	$("#fbuser_bevakning_div").html(html);
		fbuser_guard_updatelist();
		$("#fbuser_bevakning_div").fadeOut(8000);
	  }
	});	
	
	
	
}

function fbuserfav_addlink(id){


	$.ajax({
	  url: "fbuserfav_add.php",
	  type: "GET",
	  data: { id : id },
	  cache: false,
	  success: function(html){
	  	
		$("#fbuserfav_addlinkdiv_"+id).html("Sparad!");
		
		
	  }
	});	

}
function fbuserfav_remlink(id){


	$.ajax({
	  url: "fbuserfav_rem.php",
	  type: "GET",
	  data: { id : id },
	  cache: false,
	  success: function(html){
	  	
		$("#fbuserfav_fav_"+id).slideUp();
		
		
	  }
	});	

}



function fbuserprofile(id){
/*
	var fbuserfunctiondiv = document.getElementById("fbuser_actiondiv");

	if(fbuserfunctiondiv.style.display == "none")
	else	
		$("#fbuser_actiondiv").fadeOut();
	*/
		$("#fbuser_actiondiv").load("fbuserprofile.php?id="+id).fadeIn();
	
}

function fbuser_actiondiv_close(){
	$("#fbuser_actiondiv").fadeOut();
}

function fbuserprofile_photo(){
	$("#fbuserprofile_photodiv").load("fbuserprofile_photo.php");
}

function fbuser_lan(id){
	
	if(id > 0){
	
		$("#fbuseromrade_div").load("fbuserprofile_omraden.php?id="+id);
	
	} else {
		$("#fbuseromrade_div").html("<select><option>- Välj först ett län</select>");
	}
	
}
