


// flash

/*
Example Usage:
<script type="text/javascript">insertFlash('/Common/Flash/homeflash.swf', 779, 376, '', 6, 'image', '/Common/Images/homeflashalternate.jpg');</script>
*/


// Return an element by name.
function getElement(objectName)
{
    if (document.getElementById) return document.getElementById(objectName);
    if (document.all) return document.all[objectName];
    return null;
}

function fnTrapKD(btn, event)
{
    if (document.all)
    {
        if (event.keyCode == 13)
        {
            event.returnValue=false;
            event.cancel = true;
            btn.click();
        }
    }
    else if (document.getElementById)
    {
        if (event.which == 13)
        {
            event.returnValue=false;
            event.cancel = true;
            btn.click();
        }
    }
    else if(document.layers)
    {
        if(event.which == 13)
        {
            event.returnValue=false;
            event.cancel = true;
            btn.click();
        }
    }
}


var flashValid = false;

function insertFlash(filename, width, height, backgroundColour, minVersion, alternateType, alternate)
{
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if (plugin) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
		for (var i = 0; i < words.length; ++i)
		{
			if (isNaN(parseInt(words[i])))
			continue;
			var MM_PluginVersion = words[i]; 
		}
		flashValid = (MM_PluginVersion >= minVersion);
	}
	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
	&& (navigator.appVersion.indexOf("Win") != -1)) {
		document.write('<SCR' + 'IPT LANGUAGE="VBScript"\>\n'); //FS hide this from IE4.5 Mac by splitting the tag
		document.write('on error resume next \n');
        document.write('flashValid = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+minVersion+'")))\n');
		document.write('</SCR' + 'IPT\> \n');
	}
	if (flashValid) {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
		document.write('    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"');
		document.write('    id="FlashMain" width="' + width + '" height="' + height + '" align="middle">');
		document.write('    <param name="movie" value="' + filename + '">');
		document.write('    <param name="quality" value="high">');
		document.write('    <param name="wmode" value="transparent">');
		document.write('    <param name="bgcolor" value="' + backgroundColour + '">');
		document.write('    <embed src="' + filename + '" quality="high" bgcolor="' + backgroundColour + '" wmode="transparent"');
		document.write('        swLiveConnect="FALSE" width="' + width + '" height="' + height + '" name="FlashMain" id="FlashMain" align="middle"');
		document.write('        type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">');
		document.write('    </embed>');
		document.write('</object>');
	} else {
		switch (alternateType)
		{
			case 'image':
				document.write('<img src="'+alternate+'" width="'+width+'" height="'+height+'" border="0" usemap="#homemap" /><br><map name="homemap"><area shape="rect" coords="33,164,174,203" href="/Products/" title="What&#39;s New" alt="What&#39;s New"><area shape="rect" coords="559,178,676,216" href="/Recipes/" title="Recipe" alt="Recipe"></map>');
				break;
			case 'flashRequired':
				document.write('<p>Macromedia Flash version '+minVersion+' or above is required to view this content.</p>');
				document.write('<p><a href="http://www.macromedia.com/go/getflashplayer" target="_blank"><img src="http://www.macromedia.com/images/shared/download_buttons/get_flash_player.gif" border="0" width="88" height="31"/></a></p>');
				break;
			case 'showElement':
				getElement(alternate).style.display='block';
				break;
			default:
				document.write(alternate);
				break;
		}
	}
}

