/*********************************************** 
		Javascript for Manx Telecom
***********************************************/	


/**
Global variables
*/
var assets = "/themes/spring/assets/";


/**
Flash detect. boolean true/false if installed and version number accessed via flash.version
*/
if (navigator.plugins && navigator.plugins.length) {
	for (x=0; x < navigator.plugins.length; x++) {
		if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
			var flash = new Object();			
			flash.version = eval(navigator.plugins[x].description.split('Shockwave Flash ')[1].split('.')[0]);					
			break;
		}
	}
}
else if (window.ActiveXObject) {
	for (x = 2; x <= 20; x++) {
		try {
			oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
			if(oFlash) {
				var flash = new Object();				
				flash.version = x;
			}
		}
		catch(e) {}
	}
}

/**
On body load run these configuration functions
@param 		bodyRef 		object reference of the entire body of the page
*/
function fnInit(bodyRef) {
	fnFRT();
	fnFormatQuickLinks();
}


/**
Find all <h1> tags and replace content with flash movie with "Praxis" font
*/
function fnFRT() {
	if(flash) {
		var topHeadings = document.getElementsByTagName("H1");
		var text, swf;
		
		for (i=0;i<topHeadings.length;i++) {
			
			text 	= escape(topHeadings[i].innerHTML); 	// Grab text and encode
			swf		= fnMakeFlash(assets+"swf/h1.swf?t="+text,596,47);
			topHeadings[i].innerHTML = "<span class=\"hide\">"+topHeadings[i].innerHTML+"</span>"+swf;
			topHeadings[i].style.visibility = "visible";
		}
	}
}

/**
Find all "quickLinks" classes and format them to have ever 
decreasing bottom borders
*/
function fnFormatQuickLinks() {
	var unorderedLists = document.getElementsByTagName("UL");

	for (i=0;i<unorderedLists.length;i++) {
	
		/* Match quickLinks lists */
		if(unorderedLists[i].parentNode.className == "quickLinks") {
			
			var listItems 	= unorderedLists[i].getElementsByTagName("LI");
			var width		= 172;
			
			/* loop through <li>'s and sequencially reduce width */
			for (j=1;j<listItems.length;j++) {
				listItems[j].style.width = width+"px";
				width -= 11;
			}
		}
	}
}


/********************************************************************************

Name: 				Flash embed
Description:		Return flash code. Fixes Eolas update for IE as well.
@param	swf			String path to swf file
@param	width		Number value of movie width
@param	height		Number value of movie height

*********************************************************************************/

function fnMakeFlash(swf,width,height) {	
	return '<embed src="'+swf+'" menu="false" width="'+width+'" height="'+height+'" type="application/x-shockwave-flash" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" />';	
}