

// Tags to replace with heading_replace.swf, and font sizes to be used in the flash movie.
var headings = new Array( 

[".property h4", 'div {font-family: __strong; font-size: 15px; color: #231F20; }', false, false, "news_gothic.swf", null, -50, -50],
[".news_item h4", 'div {font-family: __strong; font-size: 15px; color: #231F20; }', false, false, "news_gothic.swf", null, -50, -50],
[".event h4", 'div {font-family: __strong; font-size: 16px; color: #ffffff; }', false, true, "news_gothic.swf", null, -50, -50],
/* General */
["h1", 'div {font-family: __italic; font-size: 40px; color: #000000;}', false, false, "the_serif.black.swf", null, 0, 0],
["h2", 'div {font-family: __italic; font-size: 16px; leading: -5px; color: #231F20; text-align: right;}', false, false, "the_serif.xtra-bold.swf", null, -50, -50],
["h3", 'div {font-family: __standard; font-size: 18px; color: #231F20; }', false, false, "the_serif.xtra-bold.swf", null, -50, -50],



[".pullquote blockquote", 'div {font-family: __strong; font-size: 15px; color: #707276; text-align: right;}', false, false, "news_gothic.swf", null, -50, -50],

["#dummy_heading",'div {font-family: __standard; font-size: 18px; color: #ffffff; letter-spacing: 0px;} strong {font-family: __strong; display: inline}', false, false, "news_gothic.swf"]

/*["h3", 'div {font-family: __standard; font-size: 14px; color: #009FD1;} strong {font-family: __standard; display: inline; color: #009FD1;}', false, false, "news_gothic.swf", null, -50, -50]*/

);						  

// 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(){
	
	
	if(document.all){
		var dummy = document.createElement("div");
		dummy.innerHTML = "&nbsp;";
		dummy.id = "dummy_heading";
		dummy.style.border = "none";
		dummy.style.width = "100px";
		document.body.appendChild(dummy);
	}
	
	
	
/*	var wrapper = document.getElementById("wrapper");
	if(window.getComputedStyle){
		var wrapper_position = window.getComputedStyle(wrapper, null).getPropertyValue("position");
		alert(wrapper_position);
		if(wrapper_position != "relative")
			return;
	}

	else if(wrapper.currentStyle)
		if(wrapper.currentStyle.position != "relative")
			return;*/
	
	var els;
	var el;
	var selector;

	var height;
	var width;
	var origHtml;
	var replaceText;
	var css;
	var link;
	for(var j=0; j<headings.length; j++){
		selector = headings[j][0];
		css = headings[j][1];
		
		els = getElementsBySelector(selector);
		
		var forceUpper = headings[j][2];
		var showFilters = headings[j][3];
		var flashFile = headings[j][4];
		var css_over = headings[j][5];
		
		var aa_thickness = headings[j][6];
		var aa_sharpness = headings[j][7];
		
		
		if(aa_thickness == undefined)
			aa_thickness = 0;
			
		if(aa_sharpness == undefined)
			aa_sharpness = 0;
			
			

		for(var i=0; i<els.length; i++){
			el = els[i];
			if(el) {
  			  if(css == false){
					el.skip = "skip";
					el.style.visibility = "visible";
			  }
			  else if(el.skip != "skip"){
				 el.skip = "skip";
				 if(el.tagName == "A"){
					  link = el.href;
				  }else{
					  link = "";
				  }
				 
				 height = el.offsetHeight;
				 width = el.offsetWidth;
				  

				  				  
				 if(window.getComputedStyle){
					width = window.getComputedStyle(el, null).getPropertyValue("width");
					height = window.getComputedStyle(el, null).getPropertyValue("height");
					
					width = width.substr(0, width.length - 2);
					height = height.substr(0, height.length - 2);
				}

				else if(el.currentStyle){
					var pl;
					var pr;
					var pt;
					var pb;
					pl = el.currentStyle.paddingLeft;
					pr = el.currentStyle.paddingRight;
					pt = el.currentStyle.paddingTop;
					pb = el.currentStyle.paddingBottom;

					pl = pl.substr(0, pl.length - 2);
					pr = pr.substr(0, pr.length - 2);
					pt = pt.substr(0, pt.length - 2);
					pb = pb.substr(0, pb.length - 2);
					
					height = height - pt - pb;
					width = width - pl - pr;
				}
				
				  
				  //Pull the text out of the node
				  //_origText = getInnerText(el);
				  origHtml = getInnerHtml(el);
				  if(forceUpper)origHtml = origHtml.toUpperCase();
				  replaceText = "<div>" + origHtml + "</div>";
				  
				  writeFlash(el, flashFile, width, height, "replacecontent=" + encodeURIComponent(replaceText) + "&css=" + escape(css) + "&showfilters=" + showFilters + "&link=" + link + "&css_over=" + escape(css_over) + "&aa_thickness=" + aa_thickness + "&aa_sharpness=" + aa_sharpness);

			  }
			}
		}			
	}

}

EventUtils.addEventListener(window,'load',doHeadingReplace);

