// This function which I found at 
// http://www.sovavsiti.cz/css/abbr.html
// Thanks Marek Prokop!
// fixes IE's broken implementation <abbr>
function styleAbbr() {
	var oldBodyText, newBodyText, reg
	if (isIE) {
		oldBodyText = document.body.innerHTML;
		reg = /<ABBR([^>]*)>([^<]*)<\/ABBR>/g;
		newBodyText = oldBodyText.replace(reg, '<abbr $1><span class=\"fix\" $1>$2</span></abbr>');
		document.body.innerHTML = newBodyText;
	}
}


// This function is obviously a minor
// variation on function above.
// It's not really adequate. 
// because proper browsers realize that Q tags 
// are language and encoding sensitive
// using the proper quote symbols depending on 
// nesting, context and alphabets.
// This one just stupidly swaps in the 
// English version. Oh well.
function styleQ() {
	var oldBodyText, newBodyText, reg
	if (isIE) {
		oldBodyText = document.body.innerHTML;
		reg = /<Q([^>]*)>([^<]*)<\/Q>/g;
		newBodyText = oldBodyText.replace(reg, '<q $1>&#8220;$2&#8221;</q>');
		document.body.innerHTML = newBodyText;
	}
}


// This function inserts Microsoft proprietary
// style properties to create a drop shadow.
// It's only necessary because IE doesn't support
// text-shadow as a property.
/*
function styleH1() {
	var oldBodyText, newBodyText, reg
	if (isIE) {
		oldBodyText = document.body.innerHTML;
		reg = /<H1>([^<]*)<\/H1>/g;
		newBodyText = oldBodyText.replace(reg, '<h1 style=\"filter: dropShadow\(color=#bbbbbb,offX=3,offY=3,\)\; width:100%\;\">$1</h1>');
		document.body.innerHTML = newBodyText;
	}
}
*/
// This function which I found at 
// http://www.kennsarah.net/archives/000199.shtml
// Thanks Ken & Sarah Walker!
// attempts to fix IE's broken implementation <q>
// Further study:
// http://simon.incutio.com/archive/2003/04/03/fixingQuotesWithJavascript
// http://www.kryogenix.org/days/460.html
function checkQuotes () {
	quotesElements = document.getElementsByTagName("q");
	if (quotesElements.length > 0) {
		q=quotesElements[0];
		if (q.currentStyle) {
			s = q.currentStyle;
		} else if (document.defaultView && document.defaultView.getComputedStyle) {
			s = document.defaultView.getComputedStyle(q,'');
		}
		supportsQuotes = false;
		for (prop in s) {
			if (prop.toLowerCase() == 'quotes') {
				supportsQuotes = true;
				break;
			}
		}
		if (!supportsQuotes) {
			for (var i=0; i<quotesElements.length; i++) {
				q = quotesElements[i];
				q.innerHTML = '&#8220;'+q.innerHTML+'&#8221;';
			}
		}
	}
}

window.onload = function(){
	styleAbbr()
	styleQ()
	styleH1()
};

isIE = (document.all) ? true:false;

