/* generated javascript */
var skin = 'monobook';
var stylepath = '/skins';

/* MediaWiki:Common.js */
/* Any JavaScript here will be loaded for all users on every page load. */

/**
 * JavaScript code to detect available availability of a 
 * particular font in a browser using JavaScript and CSS. 
 * 
 * Author : Lalit Patel
 * Website: http://www.lalit.org/lab/jsoncookies
 * License: Creative Commons Attribution-ShareAlike 2.5
 *          http://creativecommons.org/licenses/by-sa/2.5/
 * Version: 0.15 
 *          changed comparision font to serif from sans-serif, 
 *          as in FF3.0 font of child element didn't fallback 
 *          to parent element if the font is missing.
 * Updated: 09 July 2009 10:52pm
 * 
 */

/**
 * Actual function that does all the work. Returns an array with all the info.
 * This test will fail for the font set as the default serif font.
 * 
 * Usage: d = new Detector();
 *        d.test('font_name');
 */
var Detector = function(){
	var h = document.getElementsByTagName("BODY")[0];
	var d = document.createElement("DIV");
	var s = document.createElement("SPAN");
	d.appendChild(s);
	d.style.fontFamily = "serif";			//font for the parent element DIV.
	s.style.fontFamily = "serif";			//serif font used as a comparator.
	s.style.fontSize   = "72px";			//we test using 72px font size, we may use any size. I guess larger the better.
	s.innerHTML        = "mmmmmmmmmmlil";		//we use m or w because these two characters take up the maximum width. And we use a L so that the same matching fonts can get separated
	h.appendChild(d);
	var defaultWidth   = s.offsetWidth;		//now we have the defaultWidth
	var defaultHeight  = s.offsetHeight;	//and the defaultHeight, we compare other fonts with these.
	h.removeChild(d);
	/* test
	 * params:
	 * font - name of the font you wish to detect
	 * return: 
	 * f[0] - Input font name.
	 * f[1] - Computed width.
	 * f[2] - Computed height.
	 * f[3] - Detected? (true/false).
	 */
	function debug(font) {
		h.appendChild(d);
		var f = [];
		f[0] = s.style.fontFamily = font;	// Name of the font
		f[1] = s.offsetWidth;				// Width
		f[2] = s.offsetHeight;				// Height
		h.removeChild(d);
		font = font.toLowerCase();
		if (font == "serif") {
			f[3] = true;	// to set arial and sans-serif true
		} else {
			f[3] = (f[1] != defaultWidth || f[2] != defaultHeight);	// Detected?
		}
		return f;
	}
	function test(font){
		f = debug(font);
		return f[3];
	}
	this.detailedTest = debug;
	this.test = test;	
}

/*
 * Sexing up the Episodes.
 * 
 * Author : Matthew Kerwin
 * License: Creative Commons Attribution-ShareAlike 2.5
 *          http://creativecommons.org/licenses/by-sa/2.5/
 */

function alter_text_nodes(node) {
	var detective = new Detector();
	var acaslon   = detective.test('Adobe Caslon Pro');

	for (var i = 0; i < node.childNodes.length; i++) {
		var kid = node.childNodes[i];
		if (kid.nodeType == 3) { /* #TEXT */
			/* Personally I hate the standard 'st' and Caslon's 'ct' -MK */
			kid.data = kid.data.
				replace(/ffi/g, '\uFB03').
				replace(/ffl/g, '\uFB04').
				replace(/ff/g, '\uFB00').
				replace(/fi/g, '\uFB01').
				replace(/fl/g, '\uFB02').
				replace(/--/g, '\u2014').
				replace(/([\w,.!?"])"/g, function($0,$1){return $1 + '\u201D';}).
				replace(/([\w,.!?'])'/g, function($0,$1){return $1 + '\u2019';}).
				replace(/\.\.\./g, '\u2026').
				replace(/"/g, '\u201C').
				replace(/'/g, '\u2018');
			/* Adobe Caslon Pro has other ligatures: st:\uFB02, Th:\uE000, ct:\uE003 */
			/*if (acaslon) {
				kid.data = kid.data.
					replace(/Th/g, '\uE000');
			}*/
		} else if (kid.nodeType == 1) { /* TAG */
			alter_text_nodes(kid);
		}
	}
}

addOnloadHook(function () {
	var detective = new Detector();
	var acaslon   = detective.test('Adobe Caslon Pro');
	var styled    = false;

	var divs = document.getElementsByTagName('div');
	for (var i = 0; i < divs.length; i++) {
		var div = divs[i];
		var klass = div.getAttribute("class");
		if (/\bepisode-content\b/.test(klass)) {
			alter_text_nodes(div);
			/* get his first <P> child, and mark it */
			var first = div.getElementsByTagName('p')[0];
			if (first) {
				var pklass = first.getAttribute("class") || "";
				if (!(/\bep-first\b/.test(pklass))) {
					first.setAttribute("class", "" + pklass + (pklass ? " " : "") + "ep-first");
				}
				/* force Firefox to re-render the thingy, so the :first-letter CSS works */
				if (acaslon) {
					div.innerHTML = div.innerHTML + '<style type="text/css">div.episode-content ul { list-style:none; margin-left:0; padding-left:1.25em; text-indent:-1.25em; } div.episode-content ul > li { display: block; } div.episode-content ul > li:before { content:"\uE036\u00A0"; }</style>';
				} else {
					div.innerHTML = div.innerHTML + '';
				}
			}
		}
	}
});

/* MediaWiki:Monobook.js */
/* Any JavaScript here will be loaded for users using the MonoBook skin */