// ==UserScript==
// @name Gaia Online Search Bar
// @namespace http://eveningnewbs.googlepages.com
// @description Adds a search box to Gaia's navigation bar.
// @include http://www.gaiaonline.com/*
// @include http://gaiaonline.com/*
// ==/UserScript==
// Begin Script Update Checker code
var version_scriptURL = "http://userscripts.org/scripts/source/22187.user.js"; // Change this URL to point to a permanent copy of your own script.
var version_timestamp = 1202012186953; // Used to differentiate one version of the script from an older one. Use the Date.getTime() function to get a value for this.
if(parseInt(GM_getValue("lastUpdate","0"))+86400000<=(new Date().getTime())){GM_xmlhttpRequest({method:"GET",url:version_scriptURL+"?"+new Date().getTime(),headers:{'Cache-Control':'no-cache'},onload:function(xhrResponse){GM_setValue("lastUpdate",new Date().getTime()+"");if(parseInt(/version_timestamp\s*=\s*([0-9]+)/.exec(xhrResponse.responseText)[1])>version_timestamp){if(confirm("There is an update available for the Greasemonkey script \""+xhrResponse.responseText.split("@name")[1].split("\n")[0].replace(/^\s+|\s+$/g,"")+".\"\nWould you like to go to the install page now?")){GM_openInTab(version_scriptURL);}}}});}
// End Script Update Checker code
var ul = document.evaluate("//div[contains(@id,'gaia_menu')]/div/ul", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
if (ul.snapshotLength == 0) return;
var menuList = ul.snapshotItem(0);
var searchForm = document.createElement("li");
//searchForm.setAttribute("class", "yuimenubaritem");
searchForm.innerHTML = '<form method="get" style="border-width: 0 0 0 1px; border-style: solid; border-color: #c4c4be; padding:0px 0px 0px 10px;" action="http://gaiaonline.com/search/">' +
'<select name="type" style="font-size:10px; padding:0px; height:16px; width:150px; display:inline;" onchange="if(this.selectedIndex==2) {this.parentNode.action=\'http://www.gaiaonline.com/marketplace/itemsearch/\'; this.parentNode.val.setAttribute(\'name\', \'search\');} this.style.display=\'none\'; this.parentNode.val.style.display=\'inline\'; this.parentNode.val.value=\'Search \' + this.options[this.selectedIndex].text;">' +
'<option value="">Search...</option>' +
'<option value="">All Gaia</option>' +
'<option value="">Marketplace</option>' +
'<optgroup label="Members">' +
'<option value="users.username">by Username</option>' +
'<option value="users.interest" >by Interest</option>' +
'</optgroup>' +
'<option value="topics.tag" >Tagged Topics</option></select>' +
'<input type="text" name="val" style="display:none; font-size:11px; padding:0px; height:15px; width:150px;" onfocus="this.value=\'\' ;"/></form>';
menuList.appendChild(searchForm);