var tColour = '';

function RGBtoHex(R,G,B) {return toHex(R)+toHex(G)+toHex(B)}
function toHex(N) {	
	if (N==null) {return "00";}
	N=parseInt(N); 
	if (N==0 || isNaN(N)) {return "00";}	
	N=Math.max(0,N); 
	N=Math.min(N,255); 
	N=Math.round(N);
	return "0123456789ABCDEF".charAt((N-N%16)/16) + "0123456789ABCDEF".charAt(N%16);
}

function getTextColour(){
	var h1 = document.getElementsByTagName('h1')[0];
	if (h1.currentStyle){
		// We're in Internet Explorer
		return h1.currentStyle.color;		 
	} else if (document.defaultView.getComputedStyle){
		// We're in Mozilla
		var tColour = document.defaultView.getComputedStyle(h1,null).color;
		if (tColour.indexOf('rgb')!=-1){
			tColour = tColour.replace('rgb(','').replace(')','').split(',');
			tColour = RGBtoHex(tColour[0],tColour[1],tColour[2]);			
			return tColour;
		}
	} else {
		return '#ffffff';
	}
}


	if (typeof sIFR == "function"){
	// Global replace for cat headers
	var swfPath = frontierURL + '/dinBlack.swf?skin='+frontierSkin;
	if (lm.getElementsBy({tagName:'h1'}).length){		
		sIFR.replaceElement("h1", named({sFlashSrc: swfPath, sColor:getTextColour(), sWmode:'transparent' }));
			}
			
			sIFR.replaceElement("h2.merchHeader", named({sFlashSrc: swfPath, sColor:'#ff0099', sWmode:'transparent' }));
			sIFR.replaceElement("h2.highlightHeader", named({sFlashSrc: swfPath, sColor:'#ff0099', sWmode:'transparent',sFlashVars:'underline=true' }));
			sIFR.replaceElement("h2.restaurantSearch", named({sFlashSrc: swfPath, sColor:'#b7571b', sWmode:'transparent' }));
			sIFR.replaceElement("h2.searchHeader", named({sFlashSrc: swfPath, sColor:'#3366CC', sWmode:'transparent' }));
			sIFR.replaceElement("h2.sponsorHeader", named({sFlashSrc: swfPath, sColor:'#999999', sWmode:'transparent' }));
			sIFR.replaceElement("h2.merchHeader", named({sFlashSrc: swfPath, sColor:'#ff0099', sWmode:'transparent' }));
			sIFR.replaceElement(".hotelSummary h2", named({sFlashSrc: swfPath, sColor:'#3465ce', sWmode:'transparent' }));
			sIFR.replaceElement("h2.interstitialHeader", named({sFlashSrc: swfPath, sColor:'#000000', sWmode:'transparent' }));
			// Specific to new homepage - needs to be generic really...
			if (frontierSection == 'main'){
			sIFR.replaceElement("#homepage h2", named({sFlashSrc: swfPath, sColor:'#ff0099', sWmode:'transparent' }));
			}
	}
