// Auto Zoom
// version 0.2
// 06/28/2005
// Based on code by Jeremy Keith http://adactio.com/ and whoever wrote the Daily Kos attendant
// that I stole the addStyle function from.
//
// ==UserScript==
// @name		AutoZoom
// @namespace	http://www.tanglebones.com/
// @description 	Rewrites pages to remove regular stylesheets and apply Zoom stylesheets
// @include 	*
// ==/UserScript==

(function() {

	function addGlobalStyle(css) {
		var head, style;
		head = document.getElementsByTagName('head')[0];
		if (!head) { return; }
		style = document.createElement('style');
		style.type = 'text/css';
		style.innerHTML = css;
		head.appendChild(style);
	}


	var j = false;
	l=document.getElementsByTagName('link');
	for(i=0;i<l.length;i++) {
		if(l[i].getAttribute('type')=='text/css') {
			if(l[i].getAttribute('rev')=='zoom') {
				l[i].setAttribute('rel','stylesheet');
				l[i].disabled=false;
				j = true;
			} else {
				l[i].setAttribute('rel','alternate stylesheet');
				l[i].disabled=true;
			}
		}
	}



	if(!j) {
		addGlobalStyle('* { margin:0; padding:0; text-decoration: none; text-transform: none; font-weight: normal; font-style: normal; }');
		addGlobalStyle('html { background-color: #122; color:#dee; }');
		addGlobalStyle('body { margin: 0 1.5em; background-color: #122; color:#dee; font: 176% "Lucida Grande",Tahoma,Verdana,Geneva,Arial,Helvetica,sans-serif; line-height: 1.5; }');
		addGlobalStyle('em { font-style: italic; }');
		addGlobalStyle('strong { font-weight: bold; }');
		addGlobalStyle('h1,h2,h3,h4,h5,h6 { color: #cde; font-weight: bold; margin: 1em 0 .2em 0; }');
		addGlobalStyle('p { margin: .2em 0 1em 0; }');
		addGlobalStyle('ul,ol { margin: 0 1em; padding: 0 1em; }');
		addGlobalStyle('img { vertical-align: text-bottom; border: 0; }');
		addGlobalStyle('blockquote { margin: 1em 3em; }');
		addGlobalStyle('a { text-decoration: underline; }');
		addGlobalStyle('a:link,a:visited { color: #fc0; background-color: transparent; }');
		addGlobalStyle('a:hover,a:active { color: #122; background-color: #f90; text-decoration: none; }');
	}




}) ();

