var UNDEF = "undefined",
OBJECT = "object",
SHOCKWAVE_FLASH = "Shockwave Flash",
SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
FLASH_MIME_TYPE = "application/x-shockwave-flash",
EXPRESS_INSTALL_ID = "SWFObjectExprInst",

win = window,
doc = document,
nav = navigator,

domLoadFnArr = [],
regObjArr = [],
timer = null,
storedAltContent = null,
storedAltContentId = null,
isDomLoaded = false,
isExpressInstallActive = false;

function setFlash(p_div,p_swf,p_largeur,p_hauteur,p_wmode,p_vars) {
	if (ie && win) { // IE, the object element and W3C DOM methods do not combine: fall back to outerHTML
			document.getElementById(p_div).outerHTML = '<div id="insertswf_home"><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" WIDTH="'+p_largeur+'" HEIGHT="'+p_hauteur+'" ><PARAM NAME=movie VALUE="'+p_swf+'"><PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF><param value="'+p_wmode+'" name="wmode"><param value="'+p_vars+'" name="flashVars"></OBJECT></div>';
				
	}else{
		
		var input_mail = document.createElement('object');
		
		input_mail.setAttribute('classid', 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000');
		input_mail.setAttribute('codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0');
		
		input_mail.setAttribute("width", p_largeur);
		input_mail.setAttribute("height", p_hauteur);
		
		createObjParam(input_mail, "movie", p_swf);
		createObjParam(input_mail, "wmode", p_wmode);
		createObjParam(input_mail, "flashvars", p_vars);
		
		
				var p = document.createElement('embed');
				p.setAttribute("src", p_swf);	
				p.setAttribute("quality", "high");
				p.setAttribute("bgcolor", "#FFFFFF");
				
				p.setAttribute("width", p_largeur);
				p.setAttribute("height", p_hauteur);
				p.setAttribute('type', 'application/x-shockwave-flash');		
				//p.setAttribute('PLUGINSPAGE', 'http://www.macromedia.com/go/getflashplayer');			
		
				p.setAttribute("wmode", p_wmode);
				p.setAttribute("flashVars", p_vars);		
		
				input_mail.appendChild(p);
		
		
		var el = document.getElementById(p_div);
		
		document.getElementById(p_div).parentNode.replaceChild(input_mail, el);
	}
}			


function createObjParam(el, pName, pValue) {
	var p = document.createElement("param");
	p.setAttribute("name", pName);	
	p.setAttribute("value", pValue);
	el.appendChild(p);
}

function ua() {
	var w3cdom = typeof document.getElementById != UNDEF && typeof document.getElementsByTagName != UNDEF && typeof document.createElement != UNDEF && typeof document.appendChild != UNDEF && typeof document.replaceChild != UNDEF && typeof document.removeChild != UNDEF && typeof document.cloneNode != UNDEF,
		playerVersion = [0,0,0],
		d = null;
	if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
		d = nav.plugins[SHOCKWAVE_FLASH].description;
		if (d) {
			d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
			playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
			playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
			playerVersion[2] = /r/.test(d) ? parseInt(d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
		}
	}
	else if (typeof win.ActiveXObject != UNDEF) {
		var a = null, fp6Crash = false;
		try {
			a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".7");
		}
		catch(e) {
			try { 
				a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".6");
				playerVersion = [6,0,21];
				a.AllowScriptAccess = "always";  // Introduced in fp6.0.47
			}
			catch(e) {
				if (playerVersion[0] == 6) {
					fp6Crash = true;
				}
			}
			if (!fp6Crash) {
				try {
					a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
				}
				catch(e) {}
			}
		}
		if (!fp6Crash && a) { // a will return null when ActiveX is disabled
			try {
				d = a.GetVariable("$version");  // Will crash fp6.0.21/23/29
				if (d) {
					d = d.split(" ")[1].split(",");
					playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
				}
			}
			catch(e) {}
		}
	}
	u = nav.userAgent.toLowerCase(),
		p = nav.platform.toLowerCase(),
		webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
		ie = false,
		windows = p ? /win/.test(p) : /win/.test(u),
		mac = p ? /mac/.test(p) : /mac/.test(u);
	/*@cc_on
		ie = true;
		@if (@_win32)
			windows = true;
		@elif (@_mac)
			mac = true;
		@end
	@*/
	return { w3cdom:w3cdom, pv:playerVersion, webkit:webkit, ie:ie, win:windows, mac:mac };
}

ua();


