// ==UserScript==
// @name           Vertical Toolbar
// @namespace      http://www.xuldev.org/
// @description    Adds vertical toolbar to browser window.
// @include        main
// @compatibility  Firefox 3.0, 3.5, 3.6b4
// @author         Gomita
// @version        1.0.20080201
// @homepage       http://www.xuldev.org/misc/ucjs.php
// ==/UserScript==

(function() {
	var mode = "icons";	// "icons", "text" or "full"
	var size = "large";	// "small" or "large"
	// array of toolbar item id, "separator", "spring" and "spacer".
	var currentSet = [
		"new-tab-button",
		"new-window-button",
		"separator",
		"bookmarks-button",
		"history-button",
		"downloads-button",
		"spring",
		"cut-button",
		"copy-button",
		"paste-button",
		"separator",
		"print-button",
	];
	var toolbox = document.createElement("toolbox");
	document.getElementById("browser").insertBefore(
		toolbox, document.getElementById("sidebar-box")
	);
	toolbox.palette = document.getElementById("navigator-toolbox").palette;
	var toolbar = document.createElement("toolbar");
	toolbox.appendChild(toolbar);
	toolbar.id = "vertical-toolbar";
	toolbar.className = "chromeclass-toolbar";
	toolbar.setAttribute("mode", mode);
	toolbar.setAttribute("iconsize", size);
	toolbar.setAttribute("orient", "vertical");
	toolbar.setAttribute("flex", "1");
	currentSet.forEach(function(id){ toolbar.insertItem(id); });
	if (currentSet.indexOf("spacer") < 0 && currentSet.indexOf("separator") < 0)
		return;
	// Thanks - http://nanto.asablo.jp/blog/2007/04/22/1459018
	var style = <![CDATA[
		toolbar[orient="vertical"] > toolbarspacer { height: 15px; }
		toolbar[orient="vertical"] > toolbarseparator {
			-moz-appearance: none !important;
			margin: 0.2em 2px;
			border-bottom: 1px solid ThreeDHighlight;
			border-top: 1px solid ThreeDShadow;
			height: 2px;
			border-left: none;
			border-right: none;
		}
	]]>.toString();
	var sspi = document.createProcessingInstruction(
		'xml-stylesheet',
		'type="text/css" href="data:text/css,' + encodeURI(style) + '"'
	);
	document.insertBefore(sspi, document.documentElement);
	sspi.getAttribute = function(name) {
		return document.documentElement.getAttribute(name);
	};
}());
