var ie = (navigator.appName.indexOf("Microsoft") != -1);

if (ie){
	document.write ("<style id='hideObject'> object{display:none;} </style>");
}

document.write ("<style> object p, object img, object div, object a {display:none}</style>")

objectSwap = function(){

	var objects = document.getElementsByTagName('object');

	var stripList = [];
	for (var i=0; i<objects.length; i++){			
		var o = objects[i];	
		var h = o.outerHTML;
		var params = "";
		var hasFlash = true;
		for (var j = 0; j<o.childNodes.length; j++) {
			var p = o.childNodes[j];
			if (p.tagName == "PARAM"){
				if (p.name == "flashVersion"){
					hasFlash = detectFlash(p.value);
					if (!hasFlash){
						o.id = (o.id == undefined) ? "stripFlash"+i : o.id
						stripList.push(o.id)
						break;
					}
				} 
				params += p.outerHTML;		       
			}
		}	
		if (!hasFlash){
			continue;
		}

		if (!ie){
			continue;
		} 

		if (o.className.toLowerCase().indexOf ("noswap") != -1){
			continue;
		}		

		var tag = h.split(">")[0] + ">";			
		var newObject = tag + params + o.innerHTML + " </OBJECT>";		
		o.outerHTML = newObject;
	}
	if (ie){
		document.getElementById("hideObject").disabled = true;
	}
	stripFlash(stripList)	
}

detectFlash = function(version){
	if(navigator.plugins.length){
		var plugin = navigator.plugins["Shockwave Flash"];
		if (plugin == undefined){
			return false;
		}
		var ver = navigator.plugins["Shockwave Flash"].description.split(" ")[2];
		return (Number(ver) >= Number(version))
	} else if (ie){
		try{
			var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + version);
			return true;
		}
		catch(e){
			return false;
		}
	}
	return true;
}
stripFlash = function (stripList)
{
	for (var i=0; i<stripList.length; i++)
	{
		var o = document.getElementById(stripList[i])
		var newHTML = o.innerHTML;
		newHTML = newHTML.replace ("embed", "span");	
		var d = document.createElement("div");
		d.innerHTML = newHTML;
		d.className = o.className;
		d.id = o.id;
		o.parentNode.replaceChild(d, o);
	}
}

if (window.onload)
{
	window.onload = function(){
		window.onload;
		objectSwap();
	}
} else {
	window.onload = objectSwap;
}
