
$(function() {
	$("h1").corner("6px bevel br");
	$("#address").corner("5px");
});

/* CLIENTS */

function ajax_delete_client(id) {
	if(!confirm("Client and all related projects and tasks will be removed. Continue?")) return;
	$.ajax({
	  type: "GET",
	  url: "ajax.clients.php",
	  data: "action=delete&c_id="+id,
	  success: function(rsp){
	    if (rsp!="") {
	    	alert(rsp);
	    } else {
	    	$("#c"+id).parent("li").hide("fast");
	    }
	  }
	});
}

/* PROJECTS */

function ajax_delete_project(id) {
	if(!confirm("Project and all related requests and tasks will be removed. Continue?")) return;
	$.ajax({
	  type: "GET",
	  url: "ajax.projects.php",
	  data: "action=delete&p_id="+id,
	  success: function(rsp){
	    if (rsp!="") {
	    	alert(rsp);
	    } else {
	    	$("#p"+id).parent("li").hide("fast");
	    }
	  }
	});
}

/* REQUESTS */

function ajax_delete_request(id) {
	if(!confirm("Request and all related tasks will be removed. Continue?")) return;
	$.ajax({
	  type: "GET",
	  url: "ajax.requests.php",
	  data: "action=delete&r_id="+id,
	  success: function(rsp){
	    if (rsp!="") {
	    	alert(rsp);
	    } else {
	    	$("#r"+id).parent("li").hide("fast");
	    }
	  }
	});
}

/* TASKS */

function ajax_delete_task(t_id) {
	if (!confirm("Task will be removed. Continue?")) return;
	$.ajax({
	  type: "GET",
	  url: "ajax.tasks.php",
	  data: "action=delete&t_id="+t_id,
	  success: function(rsp){
	    if (rsp!="") {
	    	alert(rsp);
	    } else {
	    	$("#t"+t_id).hide("fast");
	    }
	  }
	});
}

/* VARIOUS */

function ajax_fetch_projects(c_id) {
	$.ajax({
	  type: "GET",
	  url: "ajax.projects.php",
	  data: "action=fetch&c_id="+c_id,
	  success: function(rsp) {
	  	$("#projects").removeOption(/./);
	  	eval("var ops="+rsp+";");
	  	$("#projects").addOption(ops, false);
	  }
	});
}