
// Tags to replace with heading_replace.swf, and font sizes to be used in the flash movie.
var headings = new Array( 
["#menu a",'div {font-family: __strong; font-size: 14px; color: #ffffff; letter-spacing: 0px; text-align: center; background-color: #00a6e2;}', true, false, "frutiger.swf", "div {font-family: __strong; font-size: 14px; color: #ffffff; letter-spacing: 0px; text-align: center; background-color: #00a6e2}"],
[".sub a", false],
["#sub_menu a",'div {font-family: __standard; font-size: 12px; color: #ffffff; letter-spacing: 0px; text-align: right; margin-right: 20px; background-color: #4087a7}', true, true, "frutiger.swf", "div {font-family: __standard; font-size: 12px; color: #ffffff; letter-spacing: 0px; text-align: right; margin-right: 20px; background-color: #4087a7;}"],
["#sidebar h3",'div {font-family: __standard; font-size: 25px; color: #ffffff; letter-spacing: 0px; text-align: right; margin-right: 10px;}', true, true, "frutiger.swf"],
["h1",'div {font-family: __standard; font-size: 35px; color: #333333; letter-spacing: 0px;} strong {font-family: __strong; display: inline}', false, false, "frutiger.swf"],
["h2",'div {font-family: __standard; font-size: 20px; color: #333333; letter-spacing: 0px;} strong {font-family: __strong; display: inline}', false, false, "frutiger.swf"],
["h3",'div {font-family: __standard; font-size: 20px; color: #555555; letter-spacing: 0px;} strong {font-family: __strong; display: inline}', false, false, "frutiger.swf"],
["h4",'div {font-family: __standard; font-size: 20px; color: #555555; letter-spacing: 0px;} strong {font-family: __strong; display: inline}', false, false, "frutiger.swf"],
["#site_search h5",'div {font-family: __standard; font-size: 18px; color: #003684; letter-spacing: 0px;} strong {font-family: __strong; display: inline}', false, false, "frutiger.swf"],
[".pullquote blockquote",'div {font-family: __standard; font-size: 16px; color: #ffffff; letter-spacing: 0px; text-align: right; leading: 2.5px;} strong {font-family: __strong; display: inline}', false, true, "frutiger.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(){
	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];

		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.innerHTML.toLowerCase().indexOf('<object')==-1 && el.skip != "skip"){
				 
				 if(el.tagName == "A"){
					  link = el.href;
				  }else{
					  link = "";
				  }
				 
				  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, flashFile, width, height, "replacecontent=" + escape(replaceText) + "&css=" + escape(css) + "&showfilters=" + showFilters + "&link=" + link + "&css_over=" + escape(css_over) );

			  }
			}
		}			
	}

}

EventUtils.addEventListener(window,'load',doHeadingReplace);
