function manage_kids(cmd,id)
{
	if(cmd == undefined) cmd = "";
	if(id == undefined) id = "";
	
	if(document.getElementById("error_msg"))
		err = document.getElementById("error_msg").value;
	else
		err = "";
	
	ajax = true;
	func = "";
	proceed=true;			
	if(ajax)
	{
		if(cmd == "")
			thisUrl = "parents_profile_body.php?mode=kids&mode2=ajax&error_msg=" + escape(err);
		else if(cmd == "delete")
			thisUrl = "parents_profile_body.php?mode=addkid&mode2=ajax&cmd=" + cmd + "&id=" + id;
		else 
		{
			arr = new Array();
			
			arr[arr.length] = "mode=addkid";
			arr[arr.length] = "mode2=ajax";
			arr[arr.length] = "cmd=" + cmd;
			arr[arr.length] = "id=" + id;
			
			if(cmd == "edit" || cmd == "add")
				func = "document.getElementById('kidname').focus();";
			else if(cmd == "insert" || cmd == "update")
			{
				proceed=false;
				if(objectVal('kidname') == "")
				{
					alert("Name is a required field");
					document.getElementById("kidname").focus();
				}
				else if(objectVal('username') == "")
				{
					alert("Username is a required field");
					document.getElementById("username").focus();
				}
				else if(objectVal('password') == "")
				{
					alert("Password is a required field");
					document.getElementById("password").focus();
				}
				else
				{			
					proceed=true;
					arr[arr.length] = "username="+objectVal('username');
					arr[arr.length] = "password="+objectVal('password');
					arr[arr.length] = "kidname="+objectVal('kidname');
					arr[arr.length] = "email="+objectVal('password');
					func = "manage_kids();";								
				}
			}
			thisUrl = "add_kid.php?" + arr.join("&");
			//alert(thisUrl);
			
		}

		if(cmd == "delete")
			proceed = confirm("Are you sure you want to delete this child account?");
		
		if(proceed)
			ajax_search("profile_body",thisUrl,false,func);
	}
	else
	{
		if(cmd == "")
		{
			if(err != "")			
				location.href="parents.php?mode=addkid&error_msg=" + escape(err);
			else
				location.href="parents.php?mode=addkid";
		}
		else if(cmd == "edit")
			location.href="parents.php?mode=editchild&id=" + id;				
	}
	
}