
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;


		var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != 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 && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
				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) {}
			}
		}
		

function hasPlayerVersion(rv) {

		var pv = playerVersion, v = rv.split(".");
		v[0] = parseInt(v[0], 10);
		v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
		v[2] = parseInt(v[2], 10) || 0;
		return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
}


function setFlash(p_div,p_swf,p_largeur,p_hauteur,p_wmode,p_vars,p_version,p_force_version) {
	if ((hasPlayerVersion(p_version))||(p_force_version==1)) {

	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"><PARAM NAME=allowScriptAccess VALUE=always><PARAM NAME=allowNetworking VALUE=all></OBJECT></div>';
				
	}else{
		if (typeof (nav.plugins[SHOCKWAVE_FLASH])!=UNDEF) {
			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);

			createObjParam(input_mail, "allowScriptAccess", "always");
			createObjParam(input_mail, "allowNetworking", "all");			
			createObjParam(input_mail, "allowFullScreen", "true");						
			
			
					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("allowScriptAccess", "always");
					p.setAttribute("allowNetworking", "all");
					p.setAttribute("allowFullScreen", "true");
			
					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);

		}else{
				alert("je suis sous un iphone");
		}
	}
}else{
	document.getElementById(p_div).innerHTML = '<b>Ce site est optimisé pour Adobe Flash Player '+p_version+'</b><br/>Vous pouvez le télécharger sur <a href="http://get.adobe.com/fr/flashplayer/?promoid=DAGAV" target="_blank">http://get.adobe.com/fr/flashplayer/?promoid=DAGAV</a><br><br>Si vous êtes tout de même certain d\'avoir la bonne version de Flash Player : <a href="index.php?forceVersion=1">cliquez ici</a>';
}

}			


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();



