/********************************************************************************
 
Name:     Flash plugin detect. Version also assigned to flash.version
 
*********************************************************************************/
var flash = new Object();	
flash.installed = false;

if (navigator.plugins && navigator.plugins.length) {
	for (x=0; x < navigator.plugins.length; x++) {
		
		if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {		
			flash.installed = true;					
			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) {		
				flash.installed = true;	
				flash.version = x;
			}
		}
		catch(e) {}
	}
}



 
	
/********************************************************************************

Name: 				Flash embed
Description:		Writeout 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

*********************************************************************************/

flash.insertMain = function(swf,width,height) {	
	if (flash.installed && flash.version >= 8 ) {
		document.write('<embed src="'+swf+'" menu="false" quality="high" width="'+width+'px" height="'+height+'px" type="application/x-shockwave-flash" salign="T" pluginspage="http://www.macromedia.com/go/getflashplayer" />');	
		document.getElementById("err").style.display = "none";
	}
	else {
		document.write('<p class="error">This website requires the latest version of the Adobe&trade; Flash player. Go to the Adobe&trade; website to update your player to the <a href="http://www.adobe.com/products/flashplayer/">latest version</a>');
		document.write('<br /><br />Or you can click here to <a href="http://www.triumph.co.uk/uk/dealers.aspx">find your nearest Triumph Dealer</a></p>');
		document.getElementById("err").style.display = "none";
	}
}
	
flash.insertCounter = function(swf,width,height,alternateContent) {	
	if (flash.installed) {
		if(flash.version < 6) {		
			//do switch for JP,DE,EN etc and put in <img src="images/h3_countdown.gif" alt="LAUNCH DATE 27TH JUNE 2007" />
			
			document.write(alternateContent);				
		}
		else {
			document.write('<embed src="'+swf+'" menu="false" quality="high" width="'+width+'px" height="'+height+'px" type="application/x-shockwave-flash" wmode="transparent" salign="T" pluginspage="http://www.macromedia.com/go/getflashplayer" />');				
		}
	}
}



/********************************************************************************

Name: 				Language detect
Description:		Extract language from query string. Default to GB (UK)

*********************************************************************************/

//find language from the query string - check if ? is in query string
if(location.href.indexOf("?") != -1) {
	var lang = location.href.split('?')[1].split('=')[1].split('-')[1].toLowerCase(); // grab YY part of 'lang=XX-YY' and toLowerCase()
}
// else set to default EN-GB (uk version)
else {
	lang = 'gb'; 
	}
	
	

/********************************************************************************

Name:     fnPopupCA

This is to popup the accessories section from flash. Pass the URL you want to open.

Description: Standard popup, but takes target from href on link.  Scrollbars are 
hidden unless screen resolution is less than 1024 x 768, when scrollbars are present.
 
*********************************************************************************/

function fnPopupCA(obj) {
  var width = 1010;
  var height = 695;
	var sScreenX = screen.width;
	var sScreenY = screen.height;
	var x = sScreenX - width;
	var y = sScreenY - height;
	var winLeft = x/2;
	var winTop =  y/2;	
	var scrollStatus = "no";
	
	if ((screen.width>=1024) && (screen.height>=768)) {
 		var scrollStatus = "no";
		}
	else {
  		var scrollStatus = "yes";
		}

	window.open(obj,"","width=" + width + ",height="+ height + ",scrollbars=" + scrollStatus + ",left=" + winLeft + ",top=" + winTop + ",resizable=yes, status=no");	
}
	
	
	
	