

// Tags to replace with heading_replace.swf, and font sizes to be used in the flash movie.
var headings = new Array( 
["#wireframe_header h1", false],						
["h1",'div {font-family: __standard; font-size: 30px; color: #306867; letter-spacing: 0px; leading: -2px;} strong {font-family: __standard; display: inline; color: #008BCD;}', false, false, "keedy_sans.swf", null, 50, 0],
["#sidebar h3",'div {font-family: __standard; font-size: 18px; color: #306867; letter-spacing: 0px; leading: -2px;} strong {font-family: __standard; display: inline; color: #008BCD;}', false, false, "keedy_sans.swf", null, 50, 0],

["#dummy_heading",'div {font-family: __standard; font-size: 18px; color: #ffffff; letter-spacing: 0px;} strong {font-family: __strong; display: inline}', false, false, "keedy_sans.swf"]
);						  

// 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 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 != "auto" ? width.substr(0, width.length - 2) : width;
					height = height != "auto" ? height.substr(0, height.length - 2) : height;
				}				
				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);
