function d2h(d) {return d.toString(16);}
function h2d(h) {return parseInt(h,16);} 
function getContrast(color1, color2) {
	var color1dec = [h2d(color1.substr(1,2)),h2d(color1.substr(3,2)),h2d(color1.substr(5,2))];
	var color2dec = [h2d(color2.substr(1,2)),h2d(color2.substr(3,2)),h2d(color2.substr(5,2))];
	return Math.abs(color1dec[0] - color2dec[0]) + Math.abs(color1dec[1] - color2dec[1]) + Math.abs(color1dec[2] - color2dec[2]);
}
function manualWrap(el) {
	function addLine(text, el, testSpan) {
		var newSpan = document.createElement("span");
		newSpan.className = "line";
		newSpan.innerHTML = text;
		el.appendChild(newSpan);
	}
	var content = el.innerHTML;
	el.innerHTML = "";
	var words = content.split(" ");
	var testSpan = document.createElement("span");
	testSpan.style.display = "inline";
	el.appendChild(testSpan);
	var lineHeight = 0;
	var newHeight = 0;
	var lastText = "";
	for (var i = 0, m = words.length; i < m; i++) {
		testSpan.innerHTML += words[i] + " ";
		newHeight = testSpan.offsetHeight;
		if (lineHeight == 0) {
			lineHeight = newHeight;
		}
		if (newHeight > lineHeight) {
			addLine(lastText, el, testSpan);
			testSpan.innerHTML = lastText = words[i] + " ";
			lastHeight = newHeight;
		} else {
			lastText += words[i] + " ";
		}
	}
	addLine(lastText + " ", el, testSpan);
	el.removeChild(testSpan);
}
if (typeof h1_color == "undefined") h1_color = "#FFFFFF";
if (typeof intro_background == "undefined") intro_background = "#FFFFFF";
if (getContrast(intro_background, "#FFFFFF") > getContrast(intro_background, "#000000")) intro_color = "#FFFFFF";
else intro_color = "#000000";
var rockwellExtraBold = { src: base + 'swf/rockwell-extra-bold.swf' };
sIFR.activate(rockwellExtraBold);
sIFR.replace(rockwellExtraBold, {
  selector: 'h1 span',
  css: '.sIFR-root { color: ' + h1_color + '; }',
  wmode: 'transparent'
});
sIFR.replace(rockwellExtraBold, {
  selector: '#quote blockquote',
  css: '.sIFR-root { color: #FFFFFF; }',
  wmode: 'transparent'
});
sIFR.replace(rockwellExtraBold, {
  selector: '#quote .author',
  css: '.sIFR-root { color: #FFFFFF; }',
  wmode: 'transparent'
});
sIFR.replace(rockwellExtraBold, {
  selector: '#home-sidebar h2',
  css: '.sIFR-root { color: #FFFFFF; }',
  wmode: 'transparent'
});
var paras = document.getElementsByTagName("P");
for (var i = 0, m = paras.length; i < m; i++) {
	if (paras[i].className == "intro") manualWrap(paras[i]);
}
sIFR.replace(rockwellExtraBold, {
  selector: '.intro .line',
  css: '.sIFR-root { color: ' + intro_color + '; font-size: 24px; }',
  fitExactly: true,
  wmode: "transparent"
});