
// Constants
var forceUpperCase = true;

// Tags to replace with heading_replace.swf, and font sizes to be used in the flash movie.
var headings = new Array( 
						  ["#page_title h1",'div {font-size: 20px; color: #00a5a3; font-family: __heading}'],
						  ["#content h2",'div {font-size: 18px; color: #90278e; font-family: __heading}'],
						  ["#team h3",'div {font-size: 13px; color: #00a5a3; font-family: __heading}'],
						  ["#softgoods h1",'div {font-size: 22px; color: #90278e; font-family: __heading}'],
						  ["#softgoods h2",'div {font-size: 16px; color: #000000; font-family: __heading}'],
						  
						  ["#awesome h2",'div {font-size: 18px; color: #65c3d6; font-family: __heading}'],
						  ["#awesome h3",'div {font-size: 16px; color: #b3d125; font-family: __heading}'],
						  ["#awesome h4",'div {font-size: 12px; color: #b3d125; font-family: __heading}'],
						  ["#b4bc h2",'div {font-size: 18px; color: #ea158e; font-family: __heading}'],
						  ["#b4bc h3",'div {font-size: 16px; color: #15b5cb; font-family: __heading}'],
						  ["#b4bc h4",'div {font-size: 12px; color: #15b5cb; font-family: __heading}'],
						  ["#benatar h2",'div {font-size: 18px; color: #b3d125; font-family: __heading}'],
						  ["#benatar h3",'div {font-size: 16px; color: #722772; font-family: __heading}'],
						  ["#benatar h4",'div {font-size: 12px; color: #722772; font-family: __heading}'],
						  ["#blast h2",'div {font-size: 15px; color: #00a4d0; font-family: __heading}'],
						  ["#blast h3",'div {font-size: 16px; color: #5db435; font-family: __heading}'],
						  ["#blast h4",'div {font-size: 12px; color: #5db435; font-family: __heading}'],
						  ["#boron h2",'div {font-size: 16px; color: #e21d37; font-family: __heading}'],
						  ["#boron h3",'div {font-size: 16px; color: #22aee7; font-family: __heading}'],
						  ["#boron h4",'div {font-size: 12px; color: #22aee7; font-family: __heading}'],		
						  ["#buzz h2",'div {font-size: 18px; color: #c1d724; font-family: __heading}'],
						  ["#buzz h3",'div {font-size: 16px; color: #14624e; font-family: __heading}'],
						  ["#buzz h4",'div {font-size: 12px; color: #14624e; font-family: __heading}'],							  
						  ["#celebrity h2",'div {font-size: 18px; color: #21a198; font-family: __heading}'],
						  ["#celebrity h3",'div {font-size: 16px; color: #d0d942; font-family: __heading}'],
						  ["#celebrity h4",'div {font-size: 12px; color: #d0d942; font-family: __heading}'],
						  ["#extremo h2",'div {font-size: 17px; color: #5f2e88; font-family: __heading}'],
						  ["#extremo h3",'div {font-size: 16px; color: #269cdb; font-family: __heading}'],
						  ["#extremo h4",'div {font-size: 12px; color: #269cdb; font-family: __heading}'],
						  ["#super h2",'div {font-size: 18px; color: #38b4ae; font-family: __heading}'],
						  ["#super h3",'div {font-size: 16px; color: #b91480; font-family: __heading}'],
						  ["#super h4",'div {font-size: 12px; color: #b91480; font-family: __heading}'],
						  ["#sweet h2",'div {font-size: 18px; color: #ffe300; font-family: __heading}'],
						  ["#sweet h3",'div {font-size: 16px; color: #028ad1; font-family: __heading}'],
						  ["#sweet h4",'div {font-size: 12px; color: #028ad1; font-family: __heading}']
						  
						  
						  
);

//var headings = new Array();

// Hide these elements until the flash is loaded.
document.write('<style type="text/css" media="screen">');
document.write(".flash_replace {display: block !important;}");
for(var g=0; g<headings.length; g++)
	document.write(headings[g][0] + " {visibility: hidden;}");
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);
		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(forceUpperCase)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);
