var protocol = "http"
if (document.location.toString().indexOf("https://") > -1) protocol += 's'

var minVer = 7

function EmbedFlashMovie(flashFile, width, height) {

	var delimiter = '?'
	if (flashFile.indexOf('?') > -1) delimiter = '&'

	if(navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
		document.write('\
			<embed src="' + flashFile + '" quality="high" pluginspage="' + protocol + '://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" wmode="transparent"></embed>\
		')
	} else {
		document.write('\
			<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="' + protocol + '://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '">\
				<param name="movie" value="' + flashFile + '">\
				<param name="quality" value="high">\
				<param name="wmode" value="transparent">\
			</object>\
		')
	}
}

function EmbedFlashInDivWithVersionCheck(divName, flashFile, width, height) {

	var delimiter = '?'
	if (flashFile.indexOf('?') > -1) delimiter = '&'
	
	var flashHTML = null
	var divObj = null
	var thisVer = null

	if (document.getElementById) {
		divObj = document.getElementById(divName)

		if (versionIsValid(minVer)) {
		
			if(navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
				flashHTML = '\
					<embed src="' + flashFile + '" quality="high" pluginspage="' + protocol + '://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" wmode="transparent"></embed>'
			} else {
				flashHTML = '\
					<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="' + protocol + '://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '">\
						<param name="movie" value="' + flashFile + '">\
						<param name="quality" value="high">\
						<param name="wmode" value="transparent">\
					</object>'
			}
			divObj.innerHTML = flashHTML
		}
	}
}

function getPlayerVersion(minVer) {
	
	var thisVer = "0"
	if(navigator.plugins && navigator.mimeTypes.length){
		var flashPlugin = navigator.plugins["Shockwave Flash"]
		if(flashPlugin && flashPlugin.description){
			thisVer = flashPlugin.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".")
			thisVer = thisVer.split(".")[0]	// major version
		}
	} else {
		try{
			var flashObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash")
			for(var i = minVer; flashObj != null; i++){
				flashObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i)
				if (flashObj != null)
					thisVer = i
			}
		}	catch(e){
		}
	}
	return thisVer
}

function versionIsValid(minVer) {

	var thisVer = getPlayerVersion(minVer)

	return (thisVer >= minVer)
}
