/* 
Use these set of scripts to define if browser has flash enabled and what version of flash player.
If cookies are enabled, it sets a cookie to remember if flash is on/off 

*/

var isIEpc = ((navigator.appVersion.indexOf("Win") != -1) && (navigator.userAgent.indexOf("MSIE") != -1));
var theCookieName = "moranandcompany"; //assign cookie name
var pluginV=5; //lowest version of plug-in acceptable


function setcookie(name,value)
{
	var argv = setcookie.arguments;
	var argc = setcookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain=(argc > 4) ? argv[4] : null;
	var secure=(argc > 5) ? argv[5] : false;
	document.cookie=name+"="+escape(value)+((expires==null)?"":(";expires="+expires.togmtstring()))+((path==null) ? "":(";path="+path))+((domain==null)?"":(";domain="+domain))+((secure==true)?";secure" : "");
}


function question()
{
if (confirm("If you have Macromedia Flash"+pluginV+".0 click 'OK'"))
	{
	return "yes";
	}
else
	{
	return "no";
	}
}


var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";
function detectFlash(){
//check if plug-in exists and will also grab version

if (navigator.plugins && navigator.plugins.length)
{
	x = navigator.plugins["Shockwave Flash"];
	if (x)
	{
		flashinstalled = 2;
		if (x.description)
		{
			y = x.description;
			flashversion = y.charAt(y.indexOf('.')-1);
		}
	}
	else
		flashinstalled = 1;
	if (navigator.plugins["Shockwave Flash 2.0"])
	{
		flashinstalled = 2;
		flashversion = 2;
	}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
	x = navigator.mimeTypes['application/x-shockwave-flash'];
	if (x && x.enabledPlugin)
		flashinstalled = 2;
	else
		flashinstalled = 1;
}
else
	if (isIEpc){
	MSDetect = "true";
	document.writeln("<SCR"+"IPT LANGUAGE=VBScript>");
	document.writeln("on error resume next");
	document.writeln('If MSDetect = "true" Then');
	document.writeln("For i = 2 to 9");
	document.writeln('If Not(IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & i))) Then');
	document.writeln("Else");
	document.writeln("flashinstalled = 2");
	document.writeln("flashversion = i");
	document.writeln("End If");
	document.writeln("Next");
	document.writeln("End If");
	document.writeln("If flashinstalled = 0 Then");
	document.writeln("flashinstalled = 1");
	document.writeln("End If");
	document.writeln("</SC"+"RIPT>");
	}

return getFlashVersion();

}

function getFlashVersion() {	
// we are looking for flash and a version 	
	if (flashinstalled==2) {
		if (flashversion>=pluginV) {
			return "yes";
		} else {
			return "no";
		}
	} else if (flashinstalled==1) {
		return "no";
	} else {
		return question();		
	} 
}	


function getcookieval(offset)	{
	var endstr = document.cookie.indexOf(";",offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset,endstr));
}


function getcookie(name) {
	var arg = name + "=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i < clen)
		{
		var j=i + alen;
		if (document.cookie.substring(i,j)==arg)
			return getcookieval(j);
		i=document.cookie.indexOf(" ",i)+1;
		if (i==0) break;
		}
	return null;
}

function hasFlash() {
//--this function returns true or false
//--depending on whether the user's browser
//--supports flash. Note if IE 4 Mac, a prompt
//--box will be displayed asking the user.
//--
//----start a testin---
	if (getcookie(theCookieName)==null) {
		theResponse = detectFlash();
		setcookie(theCookieName,theResponse,null,'/');
	}
	flash = getcookie(theCookieName);
	//alert(flash);
	if (flash =="yes") {
		return true;
	} else {
		return false;
	}
}

function flashImage(flashName,fheight,fwidth,imageName,iheight,iwidth) {
//--this places a flash movie if the user's browser has
//--flash, if not the image passed in 'imagename' is displayed
//--instead.
//--box will be displayed asking the user.
//--   NS3-PC/MAC,NS4-PC/MAC,IE4-PC/MAC,IE5-PC/MAC
//--
	if (hasFlash()) {
		document.write("<table border=0 cellspacing=0 cellpadding=0><tr><td><OBJECT classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000  codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" ID="+flashName+" WIDTH="+fwidth+" HEIGHT="+fheight+"><PARAM NAME=movie VALUE=\""+flashName+"\"><PARAM NAME=bgcolor VALUE=#ffffff><PARAM NAME=quality VALUE=high><EMBED src=\""+flashName+"\" quality=high bgcolor=#ffffff  WIDTH="+fwidth+" HEIGHT="+fheight+" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></EMBED></OBJECT></td></tr></table>");
	} else {
		document.write("<img src=\""+imageName+"\" width=\""+iwidth+"\" height=\""+iheight+"\" border=0 usemap=\"#mymap\">");
	}
}

	
	
