//
// Flash code, javascript will test flash player and if the required version is loaded will write the correct
// code to the user agent (i.e. OBJECT tag for win IE and EMBED tag for everthing else)
// The use agent will be fowarded to the fall back URL if no flash or a lower version of flash is installed
// Users with no javascript, will get the <noscript /> content
// 

var fallbackURL = "america_north.html";
var flashVer = 7;

Flash = function(swf, id, is, ia, w, h, v, c) {
	this.swf = swf;
	this.id = id;
	this.imgSrc = is;
	this.imgAlt = ia
	this.width = w;
	this.height = h;
	this.version =  (v) ? v : 5; // default to 5
	this.align = "middle"; // default to middle
	this.params = new Object();
	this.variables = new Object();
	if (c) this.color = this.addParam("bgcolor", c);
	this.addParam("quality", "high"); // default
	this.html = "";
}

Flash.prototype.setHTML = function()
{
	this.html = this.getHTML();
}

Flash.prototype.getHTML = function() 
{
    var sFlashHTML = "";
    if (window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf('mac') == -1 && navigator.userAgent.toLowerCase().indexOf('opera') == -1) 
	{ // win IE
        sFlashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '">';
        sFlashHTML += '<param name="movie" value="' + this.swf + '" />';
        if (this.getParamTags() != null) {
            sFlashHTML += this.getParamTags();
        }
        if (this.getVarPairs() != null) {
            sFlashHTML += '<param name="flashVars" value="' + this.getVarPairs() + '" />';
        }
        sFlashHTML += '</object>';
    }
    else 
	{ // not win IE
        sFlashHTML += '<embed type="application/x-shockwave-flash" src="' + this.swf + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '"';
        for (var param in this.getParams()) 
		{
            sFlashHTML += ' ' + param + '="' + this.getParam(param) + '"';
        }
        if (this.getVarPairs() != null) 
		{
            sFlashHTML += ' flashVars="' + this.getVarPairs() + '"';
        }
        sFlashHTML += '></embed>';
    }
    return sFlashHTML;	
}

Flash.prototype.getImg = function()
{
	var sImage = "";
	sImage = "<img src=\"" + this.imgSrc + "\" alt=\"" + this.imgAlt + "\"  width=\"" + this.width + "\"  height=\"" + this.height + "\" />";
	return sImage;
}

Flash.prototype.getVarPairs = function() 
{
    var variablePairs = new Array();
    for (var name in this.getVars()) 
	{
		if(Array.prototype.push == null){Array.prototype.push = function(item){this[this.length] = item;return this.length;}}
        variablePairs.push(name + "=" + escape(this.getVar(name)));
    }
    if (variablePairs.length > 0) 
	{
        return variablePairs.join("&");
    }
    else 
	{
        return null;
    }
}

Flash.prototype.write = function() 
{
	this.addVar("colour",sColour);
	this.addVar("skipIntro",1);
	if (country_that_you_wanted.indexOf("http://")==0)
	{
		this.addVar("countryurl",country_that_you_wanted);
		this.addVar("countryname",country_name);
		this.addVar("cookieRegion",map_region)
	}
	if (!this.html){this.setHTML()};
	document.write(this.html);
}

Flash.prototype.setHTML = function()
{
	if(detectVer(this.version)) 
	{
		this.html = this.getHTML();
	}		
	else
	{
		this.html = this.getImg();
	}	
}


function getVer() 
{
	var flashversion = 0;
	if (navigator.plugins && navigator.plugins.length) 
	{
		var x = navigator.plugins["Shockwave Flash"];
		if(x)
		{
			if (x.description) 
			{
				var y = x.description;
	   			flashversion = y.charAt(y.indexOf('.')-1);
			}
		}
	} 
	else 
	{
		result = false;
	    for(var i = 15; i >= 3 && result != true; i--)
		{
   			execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
   			flashversion = i;
   		}
	}
	return flashversion;
}

function detectVer(ver) 
{	
	if (getVer() >= ver) 
	{
		return true;
	} else {
		return false;
	}
}

Flash.prototype.getParamTags = function() 
{
    var paramTags = "";
    for (var param in this.getParams()) {
        paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
    }
    if (paramTags == "") {
        paramTags = null;
    }
    return paramTags;
}

Flash.prototype.addParam = function(name, value) 
{
	this.params[name] = value;
}

Flash.prototype.getParams = function() 
{
    return this.params;
}

Flash.prototype.getParam = function(name) 
{
    return this.params[name];
}

Flash.prototype.addVar = function(name, value) 
{
	this.variables[name] = value;
}

Flash.prototype.getVar = function(name) 
{
    return this.variables[name];
}

Flash.prototype.getVars = function() 
{
    return this.variables;
}


function testFlashPlayer(v,url)
{
	if (getVer()<v) 
	{
		location.replace(url);
	}
}

// test flash player version 
testFlashPlayer(flashVer,fallbackURL);

