// ==UserScript==
// @name Fit-to-window-width notice
// @author TarquinWJ 
// @namespace http://www.howtocreate.co.uk/ 
// @version 1.1
// @description  Reminds users when to enable Fit-to-window-width.
// @ujs:category browser: enhancements
// @ujs:published 2005-09-13 07:57
// @ujs:modified 2005-09-19 09:19
// @ujs:documentation http://userjs.org/scripts/browser/enhancements/ftw-notice 
// @ujs:download http://userjs.org/scripts/download/browser/enhancements/ftw-notice.js
// ==/UserScript==


/* 
 * Please see
 * http://www.howtocreate.co.uk/operaStuff/userJavaScript.html#terms
 * for License and Terms of Use
 */

document.addEventListener('load',function () {

	//configure option here; if you want the script not to run after a certain date, specify the date here
	//in the format '31 Jan 2006' (d MMM YYYY) using 3 letter english month names
	var cutoffDate = '';
//	var cutoffDate = '31 Jan 2006';

	if( !document.body || ( cutoffDate && ( ( new Date() ).getTime() > ( new Date(cutoffDate) ).getTime() ) ) ) { return; }
	//to check for a scrollbar, check if window.innerHeight != document.body.clientHeight
	//if this changes to match IE, then in strict mode will need to use documentElement instead
	if( window.innerHeight != document.body.clientHeight ) {
		var dontBreakMe =
			'position: absolute !important;\n'+
			'margin: 0px !important;'+
			'top: 0px !important;'+
			'border: 0px !important;'+
			'left: 100% !important;'+
			'width: 20px !important;'+
			'height: auto !important;'+
			'float: none !important;'+
			'bottom: auto !important;'+
			'right: auto !important;'
			'padding: 0px !important;'+
			'margin: 0px !important;'+
			'background: transparent !important;';
		var foo = document.createElement('scrwdmeas'), bar;
		foo.appendChild(document.createTextNode('x'));
		foo.setAttribute('style',dontBreakMe);
		document.documentElement.appendChild(foo);
		if( foo.offsetLeft == document.body.clientWidth ) {
			//FTW is not enabled
			foo.setAttribute('style',dontBreakMe+
				'border: 2px dotted red !important;'+
				'padding: 3px !important;'+
				'background: #fff !important;'+
				'color: red !important;'+
				'position: fixed !important;'+
				'top: auto !important;'+
				'left: 2px !important;'+
				'bottom: 2px !important;'+
				'width: auto !important;'+
				'cursor: crosshair !important;'
			);
			foo.firstChild.nodeValue = 'Choose \'View - Fit to window width\' to reformat this page to fit your screen';
			bar = window.setTimeout(function () { document.documentElement.removeChild(foo); },5000);
			foo.addEventListener('mouseover',function () { window.clearTimeout(bar); },false);
			foo.addEventListener('mouseout',function () { bar = window.setTimeout(function () { document.documentElement.removeChild(foo); },5000); },false);
			foo.addEventListener('click',function () { window.clearTimeout(bar); document.documentElement.removeChild(foo); },false);
		} else {
			document.documentElement.removeChild(foo);
		}
	}
},false);
