	
 /* **********************************************************************
 $Id: global.js,v 1.2 2007/03/30 02:11:28 beng Exp $

 Copyright (c) 2000-2007 MassMedia Studios Pty Ltd.
 68-72 Wentworth Ave, Surry Hills, NSW 2010, Australia.
 All rights reserved.

 This software is the confidential and proprietary information of 
 MassMedia Studios Pty Ltd. ("Confidential Information").  You shall not
 disclose such Confidential Information and shall use it only in
 accordance with the terms of the license agreement you entered into
 with MassMedia Studios Pty Ltd.
 ------------------------------------------------------------------------
 Author:				Ben Gillies -> ben.gillies at massmedia.com.au
 Created:				1 March 2007
 ------------------------------------------------------------------------
 Comments:	
 
 
 ********************************************************************** */
var siteTop = 'http://play.powerhousemuseum.com/';

/* IE image flicker fix */
try {
	document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

function dom_browser() {
	// browser identification based on dom capabilities
	this.myNav = this.navigator;
	this.version = this.navigator.appVersion;
	this.name = this.navigator.appName;
	this.userAgt = this.navigator.userAgent;
	this.ns4 = (document.layers) ? true : false;
	this.ns6 = (this.navigator.userAgent.indexOf("Netscape6") != -1) ? true : false;
	this.dom = (document.getElementById) ? true : false;
	this.ie4 = (document.all) ? true : false;
	this.mac = (this.version.indexOf("Mac") != -1) ? true : false;
	this.ie = (this.version.indexOf("MSIE") != -1) ? true : false;
	this.windows = (this.version.indexOf("Windows") != -1) ? true : false;
	this.hasPlugins = (this.navigator.plugins) ? true : false;
	this.ie6 = (this.version.indexOf("MSIE") != -1 && this.version.indexOf("6") != -1) ? true : false; 
	this.ie55 = (this.version.indexOf("MSIE 5.5") != -1) ? true : false;
	this.ie5 = (this.version.indexOf("MSIE 5.01") != -1) ? true : false;
	this.ns = (this.userAgt.indexOf("Netscape") != -1) ? true : false;
	this.ff = (this.userAgt.indexOf("Firefox") != -1) ? true : false;
	this.safari = (this.userAgt.indexOf("Safari") != -1) ? true : false;
}

dom_browser();

function getStyle(el,styleProp) {
	var x = document.getElementById(el);
	if (x.currentStyle) { 
		var y = x.currentStyle[styleProp];
	} else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}

//convert hsl to an html color string
function rgbToHtmlColor(myColour) {
	tempColour = myColour.split(",");
	r = parseInt(tempColour[0].substr(4));
	g = parseInt(tempColour[1]);
	b = parseInt(tempColour[2]);
	return "#" + toHex(r) + toHex(g) + toHex(b);
}

//convert decimal to hex
function toHex(decimal,places) {
   if (places == undefined || isNaN(places))  places = 2;
   var hex = new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
   var next = 0;
   var hexidecimal = "";
   decimal = Math.floor(decimal);
   while (decimal > 0) {
      next = decimal % 16;
      decimal = Math.floor((decimal - next)/16);
      hexidecimal = hex[next] + hexidecimal;
   }
   while (hexidecimal.length<places) {
      hexidecimal = "0"+hexidecimal;
	}
   return hexidecimal;
}

function setupHeadings(myLevel) {
	var myElements = document.getElementsByTagName("H" + myLevel);
	if (myLevel == 1) {
		var myFontSize = 22;
	} else {
		var myFontSize = 15;
	}
	for (var i=0; i < myElements.length; i++) {
		if (ie) {
			myHeight = myElements[i].offsetHeight + 1;
			myWidth = myElements[i].offsetWidth;
		} else {
			myHeight = myElements[i].clientHeight;
			myWidth = myElements[i].clientWidth;
		}
		myElements[i].id = "flashHeading" + myLevel + "_" + i;
		
		myColour = getStyle(myElements[i].id, "color");
		if (myColour.substr(0,4) == "rgb(") {
			myColour = rgbToHtmlColor(myColour);
			myColour = myColour.substr(1);
		} else if (myColour.substr(0,1) == "#") {
			// remove '#'..
			myColour = myColour.substr(1);
		} else {
			// default to black...
			myColour = "000000";
		}
		
		// alert("changing heading: " + myElements[i].innerHTML + " with dimensions: " + myWidth + "x" + myHeight + " with color of: 0x" + myColour);
		if (myWidth > 0 && myHeight > 0) {
			so = new SWFObject(siteTop + "common/flash/header.swf", myElements[i].id + "_flash", myWidth, myHeight, "7", "#ffffff");
			so.addParam("loop", "true");
			so.addParam("menu", "false");
			so.addParam("flashvars", "lcId=flashBanner&fontSize=" + myFontSize + "&swfString=" + escape(myElements[i].innerHTML) + "&swfHeight=" + myHeight + "&swfWidth=" + myWidth + "&swfColor=0x" + myColour);
			so.addParam("quality", "high");
			so.addParam("wmode", "transparent");
	   		so.write(myElements[i].id);
			
			myElements[i].style.padding = "0px";
			
			myElements[i].style.height = myHeight + "px";
			myElements[i].style.width = myWidth + "px";
			myElements[i].childNodes[0].style.padding = "0px";
			myElements[i].childNodes[0].style.width = myWidth + "px";

		} else {
			alert("ignoring heading: " + myElements[i].innerHTML);
		}
		
	}
}

