
function isIE(){
	var strBrowser = navigator.userAgent.toLowerCase();
	if(strBrowser.indexOf("msie") > -1 && strBrowser.indexOf("mac") < 0){
		return true;
	}else{
		return false;
	}
}



function fixActiveXProblem() {

	if (isIE()) {

		var theObjects = document.getElementsByTagName("OBJECT"); 	
		
		// need seperate array to store the reference to the object as it will be destroy once outerHTML properties is assigned
		var arrObjects = new Array(); 
		
		for (var i = 0; i < theObjects.length; i++) { 
			arrObjects[i] = theObjects[i]
		}

		for (var i = 0; i < arrObjects.length; i++) { 
			
			var theParams = arrObjects[i].getElementsByTagName("param");
			var theParamsLength = theParams.length;
				for (var j = 0; j < theParamsLength; j++) {
					if(theParams[j].name.toLowerCase() == 'flashvars'){
						var theFlashVars = theParams[j].value;
					}
				}
			var theInnnerHTML = arrObjects[i].innerHTML;
			var re = /<param name="FlashVars" value="">/ig;
			theInnnerHTML = theInnnerHTML.replace(re, "<param name='FlashVars' value='" + theFlashVars + "'>");
			arrObjects[i].outerHTML = theInnnerHTML.replace('\n', '');


		}
	}

}

function clearOuterHTML()
{
	if (isIE()) {

		var theObjects = document.getElementsByTagName("OBJECT"); 

		var arrObjects = new Array();

		for (var i = 0; i < theObjects.length; i++) { 
			arrObjects[i] = theObjects[i]
		}
		
		for (var i = 0; i< arrObjects.length; i++)
		{
			arrObjects[i].outerHTML = ""; //Clear out the HTML content of each object tag to prevent an IE memory leak issue.
		}

	}
}

window.onload = fixActiveXProblem
window.onunload = clearOuterHTML



function generateFlashObject(strFlashPath, intWidth, intHeight, strFlashVars) {

	var strFlashObjectHTML

	strFlashObjectHTML = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"'
	strFlashObjectHTML = strFlashObjectHTML + 'width="' + intWidth + '" height="' + intHeight + '">'	
	strFlashObjectHTML = strFlashObjectHTML + '<PARAM name="movie" value="' + strFlashPath + '">'
	strFlashObjectHTML = strFlashObjectHTML + '<PARAM name="quality" value="high">'
	strFlashObjectHTML = strFlashObjectHTML + '<PARAM name="flashVars" value="' + strFlashVars + '">'
	strFlashObjectHTML = strFlashObjectHTML + '<EMBED src="' + strFlashPath + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"'
	strFlashObjectHTML = strFlashObjectHTML + 'type="application/x-shockwave-flash" width="' + intWidth + '" height="' + intHeight + '" flashvars="' + strFlashVars + '"></EMBED>'
	strFlashObjectHTML = strFlashObjectHTML + '</OBJECT>'

	document.write(strFlashObjectHTML)

	


}


