/////////////////////////////////////////////////////
// Purple Monkey
//
// Flash Detection & Embedding
//
// Created By: Ray Schauer
// Created On: 4/28/2005
//
// Last Modified On: 04/21/2006
// Last Modified By: Pooja Singh
//
//
// Thank you http://www.quirksmode.org/ for the
// inspiration...
//
// No thanks to Eolas for their embed patent...
//
// ----------------------------------------------
// Accepts
// ----------------------------------------------
// URL: html for flash object embeding. The file is XHTML formatted.
// ID : id of div to replace with html from URL
// MIN: minimum version of flash which must be installed
// CUR: current high version of flash (required because IE is dumb)
//
// ----------------------------------------------
// Example Usage
// ----------------------------------------------
//
// This is where the NON-Flash version goes.
//
// ...
//
//
/////////////////////////////////////////////////////
function embedflash(url, containerid, minversion, currentversion){
// Check for proper version of flash
if (!flashInstalled(minversion,currentversion)){
return false;
}
// AJAX test
var page_request = false
if (window.XMLHttpRequest) {
// if Mozilla, Safari etc
page_request = new XMLHttpRequest();
} else if (window.ActiveXObject){
// if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try {
page_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}else {
return false;
}
// Begin embedding
page_request.onreadystatechange=function(){
loadpage(page_request, containerid);
}
page_request.open('GET', url, true);
page_request.send(null);
}
function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}
function flashInstalled(min,current) {
var installed = 0;
var version = 0;
if (navigator.plugins && navigator.plugins.length) {
// Standard Flash Detection
x = navigator.plugins["Shockwave Flash"];
if (x) {
installed = 1;
if (x.description) {
y = x.description;
version = y.charAt(y.indexOf('.')-1);
}
} else {
installed = 0;
}
} else {
// IE flash detection
current = current + 1;
for(var i=current; i>0; i--){
version = 0;
installed = 0;
try{
var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
version = i;
installed = 1;
break;
} catch(e){
// We really don't do anything with this.
// It is here to keep IE from throwing
// an error.
}
}
}
// Perform Final Test
// We MUST have min or higher
if (installed == 1 && version >= min)
return true;
else
return false;
}