

// Tags to replace with heading_replace.swf, and font sizes to be used in the flash movie.
var headings = new Array( 
						  ["#main_content h1",'div {font-family: __standard; font-size: 28px; color: #333333; letter-spacing: 0px;} strong {font-family: __bold; display: inline}', false],
						  ["#content h1",'div {font-family: __standard; font-size: 28px; color: #333333; letter-spacing: 0px;} strong {font-family: __bold; display: inline}', false],
						  ["#main_content h2",'div {font-family: __standard; font-size: 20px; color: #333333; letter-spacing: 0px;}', false]
						  );						  

// Hide these elements until the flash is loaded.
document.write('<style type="text/css">');
for(var g=0; g<headings.length; g++)
	document.write(headings[g][0] + " {visibility: hidden;} .hide {display: none}");
document.write('</style>');

function doHeadingReplace(){
	var els;
	var el;
	var selector;

	var height;
	var width;
	var origHtml;
	var replaceText;
	var css;
	for(var j=0; j<headings.length; j++){
		selector = headings[j][0];
		css = headings[j][1];
		els = getElementsBySelector(selector);
		
		var forceUpper = headings[j][2];

		for(var i=0; i<els.length; i++){
			el = els[i];
			if(el) {
			  if(el.innerHTML.toLowerCase().indexOf('<object')==-1){
				 
				  height = el.offsetHeight;
				  width = el.offsetWidth;
				  //Pull the text out of the node
				  //_origText = getInnerText(el);
				  origHtml = getInnerHtml(el);
				  if(forceUpper)origHtml = origHtml.toUpperCase();
				  replaceText = "<div>" + origHtml + "</div>";
				  writeFlash(el, "heading_replace.swf", width, height, "replacecontent=" + escape(replaceText) + "&css=" + escape(css));

			  }
			}
		}			
	}

}

EventUtils.addEventListener(window,'load',doHeadingReplace);
