
var MenuBar1 = new Spry.Widget.MenuBar("mainNav");

function getStyle(el, prop) {
	if (el.currentStyle) {
		return el.currentStyle[prop];
	} else if (document.defaultView && document.defaultView.getComputedStyle) {
		return document.defaultView.getComputedStyle(el, null)[prop];
	} else {
		return el.style[prop];
	}
}
function rgb2hex(color) {
	var colors = color.match(/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/);
	var r = parseInt(colors[1]).toString(16);
	var g = parseInt(colors[2]).toString(16);
	var b = parseInt(colors[3]).toString(16);
	if (r.length == 1) r = '0' + r;
	if (g.length == 1) g = '0' + g;
	if (b.length == 1) b = '0' + b;
	return '#' + r + g + b;
}
function applySwfText(elm) {
	var width, height, color, size, text;
	
	if (elm.offsetWidth) {
		width = elm.offsetWidth;
		height = elm.offsetHeight;
	} else {
		width = parseInt(getStyle(elm, "width"));
		height = parseInt(getStyle(elm, "height"));
	}
	height = height - parseInt(getStyle(elm, "paddingTop"));
	width = width - parseInt(getStyle(elm, "paddingLeft"));
	
	color = getStyle(elm, "color");
	if (color.indexOf("rgb") != -1)
		color = rgb2hex(color);
	
	size = getStyle(elm, "fontSize");
	if (size.indexOf("px") != -1)
		size = parseInt(size);
	else if (size.indexOf("pt") != -1)
		size = Math.round(parseFloat(size) * 1.333333);
	
	text = elm.innerHTML;
	
	html.setWidth(width);
	html.setHeight(height);
	
	// reset flasvars
	html.setFlashvars("");
	
	// add them now
	html.addFlashvar("color", color);
	
	// IE6 sucks hack:
	html.addFlashvar("width", width);
	
	html.addFlashvar("size", size);
	html.addFlashvar("text", text);
	
	//var marginTop = parseInt(getStyle(elm,"paddingTop")) + parseInt(getStyle(elm, "borderWidthTop"));
	//var marginBottom = parseInt(getStyle(elm,"paddingBottom")) + parseInt(getStyle(elm, "borderWidthBottom"));
	
	// IE6 sucks hack:
	//if (!window.XMLHttpRequest)
		html.setAdditionalProperty("style", "margin-bottom: -"+ getStyle(elm,"paddingBottom") +";margin-right: -"+width+"px;");
	//else
		//html.setAdditionalProperty("style", "margin-bottom: -"+ getStyle(elm,"paddingBottom") +";margin-right: -40px;");
	
	// reshow it
	elm.style.visibility = "visible";
	// write to the innerHTML of the element
	html.outputToInnerHTML(elm);
}

if (unFocus.FlashPlayerInfo.getVersion() >= 8 && !/noflash/.test(location))
{
	var html = new unFocus.SwfHTML();
	html.setSrc("/_images/_widgets/h1.swf");
	html.setSwliveconnect(true);
	html.setMenu(false);
	html.setQuality("high");
	html.setScale("noscale");
	html.setAllowscriptaccess("always");
	html.setWMode("transparent");
	html.setSAlign("tl");
	
	//base2.DOM.bind(document);document.querySelectorAll
	Spry.$$("#section01 h1").forEach(applySwfText);
	Spry.$$("#section02 h2").forEach(applySwfText);
	Spry.$$("#section03 h2").forEach(applySwfText);
	Spry.$$(".home h2").forEach(applySwfText);
	Spry.$$(".about #section01 p").forEach(applySwfText);
}

