

function create_item( title, remark, id )
{
	str = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" +
     " <tr><td><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" +
        "  <tr><td style=\"vertical-align:top;\"><a href=\"javascript:void(0)\" onclick=\"goto_bookmark('" + id + "')\">" + 
		title +"</a></td>" + 
         "   <td style=\"width:20px; vertical-align:top; text-align:right;\">" +
		"		<input type=\"image\" src=\"image/txtbkmkedit.jpg\" onclick=\"edit_bookmark( '" + id + "' )\" />" +
		"	</td><td style=\"width:20px; vertical-align:top; text-align:right;\">" +
		"		<input type=\"image\" src=\"image/txtbkmkdel.jpg\" onclick=\"del_bookmark( '" + id + "' )\" /></td>" +
        "  </tr></table></td>" +
     " </tr><tr><td><div>" + remark + "</div></td></tr><tr>" +
      "  <td style=\"height:12px;\" valign=\"bottom\"><hr width=100% size=1 noshade color=\"#CCCCCC\"></td></tr>" +
    "</table>"
	
	var newitem = document.createElement("div");
	newitem.innerHTML = str;
	newitem.style.padding="8px";
	return newitem;
}

function isdefined(variable) 
{
	return typeof variable == 'undefined' ? false : true;
}

////////////////////////////////////////////////////////////////////
function query_bookmarks()
{
	var node_content = document.getElementById("content");
	node_content.innerHTML = "";
	
	var str = window.external.callcfunc( 'query_bookmarks' );
	var data = eval( "(" + str + ")" );  
	for( var i = 0; i < data.length; i++ )
	{
		var title  = isdefined( data[i]['title'] )  ? data[i]['title']  : "";
		var remark = isdefined( data[i]['remark'] ) ? data[i]['remark'] : "";
		var id     = isdefined( data[i]['id'] )     ? data[i]['id'] : 0;
		var note_item = create_item( title, remark, id );
		node_content.appendChild( note_item );
	}

	var node_tip = document.getElementById("showtip");
	if( data.length == 0 )
		node_tip.style.display = "";
	else
		node_tip.style.display = "none";
}

function del_bookmark( id )
{
	window.external.callcfunc( 'del_bookmark', id );
}

function edit_bookmark( id )
{
	window.external.callcfunc( 'edit_bookmark', id  );
}

function goto_bookmark( id )
{
	window.external.callcfunc( 'goto_bookmark', id  );
}