//##################################################################################
function checkReal() {
//##################################################################################

   if (getReal()) {
	return true;
   } else {
	var agree = confirm("RealPlayer est requis pour voir cette vidéo.\nVoulez-vous l'installer ?");
	if (agree) { downloadReal(); return false; }
	else { return false; }
   }
}



//##################################################################################
function getReal() {
//##################################################################################

	var plgIe4Mac  = (navigator.appVersion.indexOf("PPC")!=-1 && navigator.userAgent.indexOf("MSIE 4")!=-1) ? true : false;

	try {
		var testObject   = new ActiveXObject("rmocx.RealPlayer G2 Control.1");
		var embedVersion = testObject.GetVersionInfo();
		
		// Real G2 Gold  : 6.0.6.131
		// RealOne       : 6.0.10
		// RealOne V2    : 6.0.11
		// RealPlayer 10 : 6.0.12
		var versionArray = embedVersion.split(".");
		var conditionA   = versionArray[0] >= 6;
		var conditionB   = versionArray[1] >= 0;
		var conditionC   = versionArray[2] >= 6;
		var conditionD   = versionArray[3] >= 131;
		
		var activeXFound = (conditionA && conditionB && conditionC && conditionD) ? true : false;		

	} catch(e) { activeXFound = false; }

	var plugInFound = getPlugIn("RealPlayer","G2","Plug-In");
	
	return (plugInFound || activeXFound || plgIe4Mac) ? true : false;	
}






//##################################################################################
function getPlugIn() {
//##################################################################################

	var allFound = false;
	var plugInsCollection = navigator.plugins;
	
	for (i=0;i<plugInsCollection.length;i++) {

		plugInDescription = " " + plugInsCollection[i].description;
		plugInName = " " + plugInsCollection[i].name;
		
		for (j=0;j<arguments.length;j++) {
		
			if (plugInDescription.indexOf(" " + arguments[j])!=-1 || plugInName.indexOf(" " + arguments[j])!=-1) {
				allFound = true;
			} else {
				allFound = false;
				break;
			}
		}
		if (allFound) { return true; }
	}
	return false;
}



//##################################################################################
function downloadReal() {
//##################################################################################

	if (navigator.appVersion.indexOf("Winx") > 0) {
		location.href='http://www.mediasynchrone.com/download/realplayer10_installer.exe';
		return false;
	}
	else {
		popLink('http://www.real.com/freeplayer/?rppr=hc.org');
		return false;
	}
}

