

// Tags to replace with heading_replace.swf, and font sizes to be used in the flash movie.
var headings = new Array( 
["#header h4",'div {font-family: __standard; font-size: 40px; color: #407183; letter-spacing: 0px; text-align: right}', false, false, "caflisch.swf"],
[".tile h3",'div {font-family: __standard; font-size: 20px; color: #ffffff; letter-spacing: 0px; leading: 0px} strong {font-family: __strong; color: #ffffff; display: inline}', true, true, "frutiger.swf"],
[".panel h3",'div {font-family: __standard; font-size: 20px; color: #628697; letter-spacing: 0px; leading: 0px} strong {font-family: __strong; color: #004159; display: inline}', true, false, "frutiger.swf"],
["h1",'div {font-family: __standard; font-size: 35px; color: #407183; letter-spacing: 0px;} strong {font-family: __standard; color: #091858; display: inline}', false, false, "frutiger.swf"],						 
["h2",'div {font-family: __standard; font-size: 35px; color: #407183; letter-spacing: 0px;} strong {font-family: __standard; color: #091858; display: inline}', false, false, "frutiger.swf"],
["h3",'div {font-family: __standard; font-size: 20px; color: #407183; letter-spacing: 0px; leading: 0px} strong {font-family: __standard; color: #091858; display: inline}', false, false, "frutiger.swf"],
["h4",'div {font-family: __standard; font-size: 20px; color: #407183; letter-spacing: 0px; leading: 0px} strong {font-family: __standard; color: #091858; display: inline}', false, false,  "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(){
	
	doTaglineReplace();
	
	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];
		var showFilters = headings[j][3];
		var flashFile = headings[j][4];

		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, flashFile, width, height, "replacecontent=" + escape(replaceText) + "&css=" + escape(css) + "&showfilters=" + showFilters);

			  }
			}
		}			
	}

}

function doTaglineReplace () {
	var tagLines = new Array(
							"our experience is your solution",				 
							"servicing Canterbury for over 120 years",
							"digital &amp; Offset print"
							);
	
	var h = getElementsBySelector("#header_tagline h4")[0];
	var t = Math.floor(Math.random() * tagLines.length)

	h.innerHTML = tagLines[t];
}


EventUtils.addEventListener(window,'load',doHeadingReplace);
//EventUtils.addEventListener(window,'load',doTaglineReplace);

