var gcid = 0;

function bookmark(cid) {
	gcid= cid;
    dojo.xhrGet( {
        url: "/bookmarker.php",
        handleAs: "text",
        timeout: 5000,
        content: {id: cid, name: cname},
        load: function(response, ioArgs) {
			bookmarkCallback(response);
        },
        error: function(response, ioArgs) {
          console.error("HTTP status code: ", ioArgs.xhr.status);
          return response;
          }
        });
}

function bookmarkCallback(data){
try {
	if(data == '"1"') {
		var notice = dojo.byId('empty_bookmarks');
		var bks = dojo.byId('bookmarks');
		if(notice)
			bks.innerHTML="";
		var newEntry = document.createElement("div");
		var link = document.createElement("a");
		link.href = "/index.php?action=jumpto&id=" + gcid;
		link.innerHTML = cname;
		newEntry.appendChild(link);
		bks.appendChild(newEntry);
	} else
		throw data;
	} catch(ex) {
		console.error(ex);
	}
}
