<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://livemargins/skin/overlay.css" type="text/css"?>
<?xml-stylesheet href="chrome://livemargins/skin/css/monitor.css" type="text/css"?>
<!DOCTYPE overlay SYSTEM "chrome://livemargins/locale/livemargins.dtd">

<overlay id="lm4-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
	<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js" />
	<script type="application/x-javascript" src="moa.js"/>
	<script type="application/x-javascript" src="logging.js"/>
	<script type="application/x-javascript" src="overlay.js"/>
	<script type="application/x-javascript" src="monitor.js"/>
	<script type="application/x-javascript" src="webAppManager.js"/>
	<script type="application/x-javascript" src="flashExtractor.js"/>
	<script type="application/x-javascript" src="dragdrop.js"/>
	<script type="application/x-javascript" src="baiduapp.js"/>
	<script type="application/x-javascript" src="appintent.js" />
	<script type="application/x-javascript">
		// Register apps
		Components.utils['import']('resource://livemargins/apps/gallery.js');
		Components.utils['import']('resource://livemargins/apps/music.js');
		Components.utils['import']('resource://livemargins/apps/search.js');
		Components.utils['import']('resource://livemargins/apps/weather.js');			
	</script>
	<script type="application/x-javascript">
		// hide chrome for about:appcenter
		(function() {
			if (!XULBrowserWindow || !XULBrowserWindow.hideChromeForLocation) {
				return;
			}
			return;
			
			var prevFunc = XULBrowserWindow.hideChromeForLocation;
			var logger = utils.logger('LM4.test');
			XULBrowserWindow.hideChromeForLocation = function(aLocation) {
				// call prevFunc by applying XULBrowserWindow object, or an error will occur about this.in...
				return (aLocation.toString() == 'about:appcenter') || prevFunc.apply(XULBrowserWindow, [aLocation]);
			}
		})();
	</script>
	<stringbundleset id="stringbundleset">
		<stringbundle id="livemarginsStrings" src="chrome://livemargins/locale/livemargins.properties"/>
	</stringbundleset>
	
	<!-- Capture panel -->
	<popupset id="mainPopupSet">
		<panel id="capture-panel" flex="1" noautohide="true" hidden="true">
			<hbox id="capture-div" width="200px" height="200px">
				<vbox id="selection-borders" flex="1">
					<hbox class="selectionbox-border" id="selection-box-top"/>
					<hbox id="selection-box-middle">
						<hbox class="selectionbox-border" id="selection-box-left"/>
						<hbox id="selection-box" onmousedown="MOA.LM4.Monitor.startMove(event);">
							<hbox id="selectionbox-control-set" flex="1" style="visibility:hidden">
								<vbox id="left-box" align="start">
									<hbox class="selectionbox-resizer" id="selectionbox-top-left-resizer" style="cursor:nw-resize" onmousedown="MOA.LM4.Monitor.startResize(event,'top-left');event.stopPropagation();"/>
									<spacer flex="1"/>
									<hbox class="selectionbox-resizer" id="selectionbox-center-left-resizer" style="cursor:w-resize"  onmousedown="MOA.LM4.Monitor.startResize(event,'left');event.stopPropagation();"/>
									<spacer flex="1"/>
									<hbox class="selectionbox-resizer" id="selectionbox-bottom-left-resizer" style="cursor:sw-resize" onmousedown="MOA.LM4.Monitor.startResize(event,'bottom-left');event.stopPropagation();"/>
								</vbox>
								<spacer flex="1"/>
								<vbox id="middle-box" align="center">
									<hbox class="selectionbox-resizer" id="selectionbox-top-center-resizer" style="cursor:n-resize" onmousedown="MOA.LM4.Monitor.startResize(event,'top');event.stopPropagation();"/>
									<spacer flex="1"/>
									<button id="selectionbox-ok" image="chrome://livemargins/skin/scissors-white.png" onclick="MOA.LM4.Monitor.endCapture(event);"/>
									<spacer flex="1"/>
									<hbox class="selectionbox-resizer" id="selectionbox-bottom-center-resizer" style="cursor:s-resize" onmousedown="MOA.LM4.Monitor.startResize(event,'bottom');event.stopPropagation();"/>
								</vbox>
								<spacer flex="1"/>
								<vbox id="right-box"  align="end">
									<hbox class="selectionbox-resizer" id="selectionbox-top-right-resizer" style="cursor:ne-resize" onmousedown="MOA.LM4.Monitor.startResize(event,'top-right');event.stopPropagation();"/>
									<spacer flex="1"/>
									<hbox class="selectionbox-resizer" id="selectionbox-center-right-resizer" style="cursor:e-resize" onmousedown="MOA.LM4.Monitor.startResize(event,'right');event.stopPropagation();"/>
									<spacer flex="1"/>
									<hbox class="selectionbox-resizer" id="selectionbox-bottom-right-resizer" style="cursor:se-resize" onmousedown="MOA.LM4.Monitor.startResize(event,'bottom-right');event.stopPropagation();"/>
								</vbox>
							</hbox>
						</hbox>
						<hbox class="selectionbox-border" id="selection-box-right" flex="1"/>
					</hbox>
					<hbox class="selectionbox-border" id="selection-box-bottom" flex="1"/>
				</vbox>
			</hbox>
		</panel>
	</popupset>
	
    <!-- App intent context menu -->
    <popup id="contentAreaContextMenu">
       <menu image="chrome://livemargins/skin/appcenter-16.png" class="menu-iconic" id="appIntentMenuItem" hidden="true" label="&appIntentMenuLabel;" insertbefore="share_all_cn_menuitem_default">
           <menupopup id="appIntentMenuPopup" oncommand="MOA.LM4.AppIntent.onContextCommand(event, this);"></menupopup>
       </menu> 
    </popup>
	
	<toolbarpalette id="BrowserToolbarPalette">
		<toolbarbutton
			id="favpart-button"
			class="toolbarbutton-1 chromeclass-toolbar-additional" 
			label="&favpart_button_label;" 
			tooltiptext="&favpart_button_label;" 
			oncommand="try {MOA.LM4.Monitor.capture();} catch (e) {alert(e)}"/>
		<toolbarbutton 
			id="appcenter-button"
			type="menu-button"
			class="toolbarbutton-1 chromeclass-toolbar-additional" 
			label="&livemargin3_button_label;" 
			tooltiptext="&livemargin3_button_label;"
			oncommand="if (switchToTabHavingURI) { switchToTabHavingURI('about:appcenter', true); } else { openUILink('about:appcenter'); }">
			<menupopup id="apps-popup" 
					   position="after_end" 
					   onpopupshowing="MOA.LM4.onAppMenushowing(this, event);">
			</menupopup>
		</toolbarbutton>
	</toolbarpalette>
	
</overlay>
