/* flash version */
var flashVersion = 6;

/* flash release version */
var flashRelease = "6,0,67,0";

/**
  * Detects if is flash compatible
  *
  * @return boolean
  */
function isFlashCompatible() {
	var pluginVersion;
	if(navigator.plugins && navigator.mimeTypes.length){
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");		
		for (var i = 0; i < words.length; ++i) {
			if (isNaN(parseInt(words[i])))
				continue;
			pluginVersion = words[i];
		}
	}else{
		try{
			var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			for (var i=3; axo!=null; i++) {
				axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
				pluginVersion = i;
			}
		}catch(e){
		}
	}
	
	return pluginVersion >= flashVersion;
}

/**
  * Writes the flash code
  * 
  * @param string swf
  * @param string flashVarString
  * @param int width
  * @param int height
  * @param string bgcolor
  * @param string menu
  * @param string mode
  * @param string q
  * @param string id
  */
function writeFlash(swf,flashVarString,w,h,bgcolor,menu,mode,q,id) {
  if (isFlashCompatible()) {
     document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
     +'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+flashRelease+'" '
     +'width="'+w+'" height="'+h+'" id="'+id+'" align="" />'
     +'<param name="movie" value="'+swf+'" />'
     +'<param name="menu" value="'+menu+'" /> '
     +'<param name="quality" value="'+q+'" /> '
     +'<param name="wmode" value="'+mode+'" /> '
     +'<param name="bgcolor" value="'+bgcolor+'" /> '
     +'<param name="flashvars" value="'+flashVarString+'" /> '
     +'<embed src="'+swf+'" flashvars="'+flashVarString+'" menu="'+menu+'" quality="'+q+'" wmode="'+mode+'" '
     +' bgcolor="'+bgcolor+'"  width="'+w+'" height="'+h+'" name="'+swf+'" '
     +' align=""  type="application/x-shockwave-flash" '
     +' pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object> ');     
  } else {
     //behaviour for if there is no flash player
     document.write('You require Flash Player '+flashVersion+' or later to use this site. ');
     document.write('<em><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">');
     document.write('Click here to install it now.</a></em>');

     //this can be replaced by anything you want
     //e.g. document.location.replace("text.html");
  }
}
