<!--

//****************************************************************************
// Copyright (C) 2006 CDSM Interactive Solutions Ltd. All Rights Reserved.
//****************************************************************************

/**
 * HTML to Flash Converstion Functions
 *
 * Set of functions used for replacing HTML with flash a flash move.  This should only happen if 
 * the Flash player is installed on the client PC.  The parent script should check for the Flash Player version
 * before running this script.
 *
 *  Note: These functions are used by "nadiaFunctions.js" and "audioBtnFunctions.js"
 * 
 * @author 	Andrew Evans
 * @version	1.0.0 - initial version (25/10/2006)
 */

function init() {
	//alert("...before replaceMp3LinkWithSwf");
	replaceMp3LinkWithSwf();
	//alert("...after replaceMp3LinkWithSwf");
	//alert("...before replaceNadiaImgWithSwf");
	replaceNadiaImgWithSwf();
	//alert("...after replaceNadiaImgWithSwf");
}

/**
 * Returns background colour of the tag passed as an argument
 */
function getBgColor(aTag) {
	
	if(document.defaultView && document.defaultView.getComputedStyle) {// IS MOZILLA BASED BROWSER
     	var rgbStr = document.defaultView.getComputedStyle(aTag, '').getPropertyValue("color");
    	 
		var rgb = rgbStr.split(",");
		var r = rgb[0].substr(4);
		var g = rgb[1].substr(1);
		var bLength = rgb[0].length;
		var b = rgb[0].substr(0,bLength-1);
		
		var c = "#" + RGBtoHex(r,g,b);
		// alert('DOM way: '+c);
    }else if(document.uniqueID && aTag.currentStyle){ // IS INTERNET EXPLORER
     	var c = aTag.currentStyle.color;
		//alert('IE way: '+c);
    }else {
		var c = aTag.style.color;
		//alert('Catch-all way: '+c);
	}
	
	var flashColor = "0x" + c.substr(1);
	
	//alert('flashColor: ' + flashColor);
 	return flashColor;
	
}


/**
 * Return first "a" element in element (elem) argument
 */
function getFirstLink(elem) {
	if( elem != null ){
		var i = 0;
		var loopLength = elem.childNodes.length;
		var currNode;
		var str = "";
		
		for (i; i<loopLength; i++) {
			
			currNode = elem.childNodes[i];
			
			if (currNode.nodeName.toLowerCase() == "a") {
				return currNode;
			}
			
		}
	}
	
}

/**
 * Returns URL from the href of the "aElement" passed as an argument
 */
function getURL(aElement) {
	
	return aElement.getAttribute("href");
	
}

/**
 * Removes the image within element passed as an argument (elem)
 */
function removeImage(elem) {
	
	var i = 0;
	var loopLength = elem.childNodes.length;
	var currNode;
	var str = "";
	
	for (i; i<loopLength; i++) {
		
		currNode = elem.childNodes[i];
		
		if (currNode.nodeName.toLowerCase() == "img") {
			elem.removeChild(currNode);
			return true;
		}
		
	}
	
	return false;
	
}


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);
}

-->
