function SaveBookmark(book_id)
	{
	jq.post("ajax.php?action=saveBookTitle",
		{
		book_id : book_id,
		book_title : jq("#book_edit"+book_id).attr("value")
		},
		function(data)
			{
			jq("#book"+book_id).html(data);
			},
		"html");
	}
	
	
function EditBookTitle(book_id)
	{

	jq.post("ajax.php?action=editBookTitle",
		{
		book_id : book_id
		},
		function(data)
			{
			jq("#book"+book_id).html(data);
			},
		"html");
	}

	

	
function addPostBookmark(post_id,b_title)
	{
	var from_left = (jq(document).attr("width")/2)-250;
	jq("body").append("<div id='floater' style='background:#F5F5F5;display:block;width:500px;height:100px;position:fixed;top:200px;left:"+from_left+"px'><table width='100%'><tr><td align='center'><b>Please enter bookmark title:</b><br><br><input type='text' style='width:400px;' id='book_title' value='"+b_title+"'><br><br><a href='javascript:;' onclick='AddBookmark(\""+post_id+"\")'>OK</a>&nbsp;<a href='javascript:;' onclick='jq(\"#floater\").remove();'>Close</a></td></tr></div>");
	jq("#floater").css("opacity","0");
	jq("#floater").animate({opacity:'1'},500);
	}
function AddBookmark(post_id)
	{
	jq.post("ajax.php?action=addbookmark",
		{
		post_id : post_id,
		title : jq("#book_title").attr("value")
		},
		function(data)
			{
			alert("Bookmark added!");
			jq("#floater").remove();
			},
		"html");
	}

function get_data(URL, destination){
  dest = destination;
  //cDiv = document.getElementById(dest);
  //contentDiv.innerHTML = "<img src='load.gif'>";
  if(window.XMLHttpRequest){
	request = new XMLHttpRequest();
    request.onreadystatechange = processStateChange;
    request.open("GET", URL, true);
    request.send(null);
  } else if (window.ActiveXObject) {
    request = new ActiveXObject("Microsoft.XMLHTTP");
    if (request) {
	request.onreadystatechange = processStateChange;
	request.open("GET", URL, true);
	request.send();
    }
  }
}
/////////////////
function processStateChange(){
  if (request.readyState == 4){
    contentDiv = document.getElementById(dest);
    if (request.status == 200){
	response = request.responseText;
	contentDiv.innerHTML = response;
	}
  }
}

function removeitem(area,areaval)
	{
	var allarea = document.getElementById(area).value;
	var pos = allarea.search(areaval+",");
	var ln = areaval.length;
	document.getElementById(area).value = allarea.substring(0,pos)+allarea.substring(pos+ln+1,allarea.length);
	get_data('ajax.php?area='+area+'&namebyid='+document.getElementById(area).value,area+'res');
	}
function displayitem(areaname,areasend,areainput,areaoutput)
	{
	document.getElementById(areaoutput).style.display="";
	get_data("ajax.php?area="+areasend+"&name="+document.getElementById(areainput).value,areaoutput);
	}

function get_data_run(URL, destination){
  dest = destination;
  //cDiv = document.getElementById(dest);
  //contentDiv.innerHTML = "<img src='load.gif'>";
  if(window.XMLHttpRequest){
	request = new XMLHttpRequest();
    request.onreadystatechange = processStateChangeRun;
    request.open("GET", URL, true);
    request.send(null);
  } else if (window.ActiveXObject) {
    request = new ActiveXObject("Microsoft.XMLHTTP");
    if (request) {
	request.onreadystatechange = processStateChangeRun;
	request.open("GET", URL, true);
	request.send();
    }
  }
}
function processStateChangeRun(){
  if (request.readyState == 4){
    contentDiv = document.getElementById(dest);
    if (request.status == 200){
	response = request.responseText;
	eval(response);
	}
  }
}

function AJAXInteraction(url, callback) 
{
var req = init();
req.onreadystatechange = processRequest;

function init() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if (window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP");
}
}

function processRequest() {
if (req.readyState == 4) {
if (req.status == 200) {
//if (callback) callback(req.responseXML);
if (callback) document.getElementById(callback).innerHTML = req.responseText;
}
}
}

this.doGet = function() {
req.open("GET", url, true);
req.send(null);
}

this.doPost = function(body) {
req.open("POST", url, true);
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req.send(body);
}
}

function makeRequest(ajaxurl,retnarea) {
var ai = new AJAXInteraction(ajaxurl,retnarea);
ai.doGet();
}


