/* Right Context Menu configuration for anonymous users:
   Menu is built from four array items: title, link, show if page or headpage, show if namespace.
   Link is not created if it's 0, otherwise it's evaluated.
   Second array is displayed only in edit mode.

   Some usefull variables:
   node.hns = headpage id;
   node.isdir = node is namespace;
   node.dokuid = the DW id (namespace parent in case of headpage);
   id = the DW id of the selected node (headpage id in case of headpage);
   this.config.urlbase = Url Base;
   this.config.sepchar = Url separator;
*/

/*Custom User Functions
Insert your custom functions here.
*/

function indexmenu_srchpage(u,s,isdir,nid) {
    var r = prompt("Insert keyword(s) to search for within this namespace","");
    if (r)
        {
	    var fnid = nid;
	    if (isdir == "0") {
		fnid = fnid.substring(0,nid.lastIndexOf(s));
	    }
	    var b=u,re = new RegExp(s, 'g');
	    fnid = fnid.replace(re, ":");
	    b += (u.indexOf("?id=") < 0) ? '?id=': '';
	    window.location.href = indexmenu_getid(b,r+" @"+fnid)+"do=search";
	}
}

function indexmenu_getid(u,id) {
    var url=(u||'')+encodeURI(id||'');
    url += (u.indexOf("?") < 0) ? '?': '&';
    return url;
}
