// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all && window.print && !window.opera && /MSIE [5678]/.test(navigator.userAgent);
//var IE = true; //(navigator.appName == 'Microsoft Internet Explorer');
//var n6 = document.getElementById && !document.all;


//-------------------------------------------------------------------------------------
// ouvre une fenetre en popup
//-------------------------------------------------------------------------------------
// récupère un objet
//-------------------------------------------------------------------------------------
function getid ( id ) { if (document.getElementById) return(document.getElementById(id)); else if (document.all) return(document.all[id]); }

//-------------------------------------------------------------------------------------
// affiche ou no des élements id
//-------------------------------------------------------------------------------------
function show ( idname ) {	if (getid(idname)) getid(idname).style.display = 'block'; }
function hide ( idname ) {	if (getid(idname)) getid(idname).style.display = 'none'; }

//-------------------------------------------------------------------------------------
// inverse les video / slides
//-------------------------------------------------------------------------------------
function swap () {
	
	getid('div_video').id = 'div_temp';
	getid('div_slides').id = 'div_video';
	getid('div_temp').id = 'div_slides';
}
//-------------------------------------------------------------------------------------
// création des objets Media
//-------------------------------------------------------------------------------------
function create_swf () {

	document.open();

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%" class="swf" ');
	document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0">');
	document.write('<param name="movie" value="'+ video_file +'">');
	document.write('<param name="wmode" value="transparent">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="LOOP" value="false">');
	document.write('<embed src="'+ video_file +'" width="100%" height="100%" loop="false" quality="high" wmode="transparent" ');
	document.write('pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash">');
	document.write('</embed>');
	document.write('</object>');
	
	document.close()
}
//-------------------------------------------------------------------------------------
var wmv = true;
var video_player = null;

function create_wmv () {

	var clsid1 = '22d6f312-b0f6-11d0-94ab-0080c74c7e95'; // v 9.
	var clsid = "6BF52A52-394A-11d3-B153-00C04F79FAA6"; // 6/7/8/9/10/11

//video_height += 68;
	
	//document.open();
	
	video = '<OBJECT ';
	video += 'ID="video_player" NAME="video_player" ';
	video += 'WIDTH="'+ video_width +'" HEIGHT="'+ video_height +'" ';
	video += 'CLASSID="CLSID:'+ clsid +'" ';
	video += 'CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ';
	video += 'STANDBY="Loading Microsoft Windows Media Player components" ';
	video += 'TYPE="application/x-oleobject" ';
	video += 'onMouseOver="this.uiMode=\'mini\'" ';
	video += 'onMouseOut="this.uiMode=\'none\'" ';
	video += 'onMouseDown="if(video_paused) video_play(); else video_pause();"';
	video += '>';
	//onmousedown=\"if(video_paused) video_play(); else video_pause();\" onmouseover=show('div_player'); sonmouseout=hide('div_player');
	video += '<PARAM NAME="filename" VALUE="/CORE/asx.php?id='+ idd +'">';
	video += '<PARAM NAME="URL" VALUE="/CORE/asx.php?id='+ idd +'">';
	video += '<PARAM NAME="autostart" VALUE='+ video_autostart +'">';
	video += '<PARAM NAME="transparentatstart" VALUE=1>';
	video += '<PARAM NAME="showstatusbar" VALUE=0>'; //"+ video_status +">";
	//video += "<PARAM NAME=ShowPositionControls  value=0>";
	//video += "<PARAM NAME=ShowControls VALUE="+ video_control +">";
	video += "<PARAM NAME=uiMode VALUE='none'>";
	//video += "<PARAM NAME=AllowChangeDisplaySize VALUE=1>";
	//video += "<PARAM NAME=DisplaySize VALUE=0>";
	//video += "<PARAM NAME=ShowDisplay VALUE=0>";
	//video += "<PARAM NAME=AutoSize VALUE=0>";
	//video += "<PARAM NAME=AnimationAtStart VALUE=0>";
	video += "<PARAM NAME=EnableFullScreenControls VALUE=1>";
	video += "<PARAM NAME=AutoRewind VALUE=0>";
	video += "<PARAM NAME=EnableContextMenu VALUE=1>";
	//video += "<PARAM NAME=windowlessVideo VALUE=1>";
	//video += "<EMBED ID='video_player' NAME='video_player' type='application/x-mplayer2' pluginspage='http://www.microsoft.com/windows/mediaplayer/download/default.asp' SRC='/CORE/asx.php?id="+ idd +"' width="+ video_width +" height="+ vh +" AutoStart="+ video_autostart +" TransparentAtStart=1 ShowStatusBar="+ video_status +" ShowPositionControls=0 ShowControls="+ video_control +" AllowChangeDisplaySize=1 DisplaySize=0 ShowDisplay=0 AutoSize=0 AnimationAtStart=0 EnableFullScreenControls=1 AutoRewind=0 EnableContextMenu=0 windowlessVideo=1></EMBED>";
	
	video += '<embed ';
	video += 'id="video_player" name="video_player" ';
	video += 'width="'+ video_width +'" height="'+ video_height +'" ';
	video += 'type="application/x-mplayer2" pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" ';
	video += 'src="/CORE/asx.php?id='+ idd +'" ';
	video += 'loop=false autostart="'+ video_autostart +'" showstatusbar=0 ShowControls=1 EnableFullScreenControls=1 AutoRewind=0 EnableContextMenu=0></embed>';

	video += '</OBJECT>';
	
	document.getElementById('div_video').innerHTML = video;
	//document.close();
	
	video_player = document.getElementById("video_player");
	//video_player.SendPlayStateChangeEvents = true;

}
function create_wmv_alternative () {

	video = '<object ';
	video += 'id="video_player" name="video_player" ';
	video += 'width="'+ video_width +'" height="'+ video_height +'" ';
	video += 'classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" ';
	video += 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ';
	video += 'standby="Loading Microsoft Windows Media Player components" ';
	//video += 'type="application/x-oleobject" ';
	video += 'onMouseOver="this.uiMode=\'mini\'" ';
	video += 'onMouseOut="this.uiMode=\'none\'" ';
	video += 'onMouseDown="if(video_paused) video_play(); else video_pause();"';
	video += '>';
	//onmousedown=\"if(video_paused) video_play(); else video_pause();\" onmouseover=show('div_player'); sonmouseout=hide('div_player');
	video += '<PARAM NAME="filename" VALUE="/CORE/asx.php?id='+ idd +'">';
	video += '<PARAM NAME="URL" VALUE="/CORE/asx.php?id='+ idd +'">';
	video += '<PARAM NAME="autostart" VALUE='+ video_autostart +'">';
	video += '<PARAM NAME="transparentatstart" VALUE=1>';
	video += '<PARAM NAME="showstatusbar" VALUE=0>'; //"+ video_status +">";
	//video += "<PARAM NAME=ShowPositionControls  value=0>";
	//video += "<PARAM NAME=ShowControls VALUE="+ video_control +">";
	video += "<PARAM NAME=uiMode VALUE='none'>";
	//video += "<PARAM NAME=AllowChangeDisplaySize VALUE=1>";
	//video += "<PARAM NAME=DisplaySize VALUE=0>";
	//video += "<PARAM NAME=ShowDisplay VALUE=0>";
	//video += "<PARAM NAME=AutoSize VALUE=0>";
	//video += "<PARAM NAME=AnimationAtStart VALUE=0>";
	video += "<PARAM NAME=EnableFullScreenControls VALUE=1>";
	video += "<PARAM NAME=AutoRewind VALUE=0>";
	video += "<PARAM NAME=EnableContextMenu VALUE=1>";
	//video += "<PARAM NAME=windowlessVideo VALUE=1>";
	//video += "<EMBED ID='video_player' NAME='video_player' type='application/x-mplayer2' pluginspage='http://www.microsoft.com/windows/mediaplayer/download/default.asp' SRC='/CORE/asx.php?id="+ idd +"' width="+ video_width +" height="+ vh +" AutoStart="+ video_autostart +" TransparentAtStart=1 ShowStatusBar="+ video_status +" ShowPositionControls=0 ShowControls="+ video_control +" AllowChangeDisplaySize=1 DisplaySize=0 ShowDisplay=0 AutoSize=0 AnimationAtStart=0 EnableFullScreenControls=1 AutoRewind=0 EnableContextMenu=0 windowlessVideo=1></EMBED>";
	
	video += '<embed ';
	video += 'id="video_player" name="video_player" ';
	video += 'width="'+ video_width +'" height="'+ video_height +'" ';
	video += 'type="application/x-mplayer2" pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" ';
	video += 'src="/CORE/asx.php?id='+ idd +'" ';
	video += 'loop="false" autostart="'+ video_autostart +'" fullscreen="1" autorewind="0"></embed>';

	video += '</OBJECT>';
	
	document.getElementById('div_video').innerHTML = video;
	//document.close();
	
	video_player = document.getElementById("video_player");
	//video_player.SendPlayStateChangeEvents = true;

}
//-------------------------------------------------------------------------------------
function create_flv () {

	//video_height += 31;

	var flashvars = {};

	// image de fonds
	//flashvars.image = "/CORE/images/video/video_bd.jpg";
	//flashvars.skin = "/CORE/flv_skin_stylish.swf";
	flashvars.controlbar = "over";
	flashvars.file = video_file;
	flashvars.streamer = video_streamer;
	flashvars.autostart = video_autostart;
	flashvars.backcolor = '#000000';
	flashvars.frontcolor = '#FFFFFF';
	flashvars.lightcolor = '#CCCCCC';
		
	var params = { wmode:'transparent', allowfullscreen:'true', allowscriptaccess:'always', controlbar:"over" };
	var attributes = { id:"video_player", name:"video_player" };

	swfobject.embedSWF('/CORE/flv_player.swf', 'container', video_width, video_height, '9.0.124', false, flashvars, params, attributes);

}

//-------------------------------------------------------------------------------------
function plugin_wmv() {

	// la bulle ?
	firefox = document.all? document.all["div_firefox"] : document.getElementById? document.getElementById("div_firefox") : "";
	
	// cree la bulle si elle n'existe pas
	if (!firefox) {

		firefox = document.createElement('div');
		firefox.id = 'div_firefox';
		firefox.style.zIndex = 9999;

		firefox.style.position = 'absolute';
		firefox.style.visiblity = 'visible';
		firefox.style.display = 'block';

		//firefox.style.left = 10;
		//firefox.style.top = 10;
		firefox.style.width = '95%'; //(template_width-40);
		firefox.style.height = '95%'; //(template_height-40);

		firefox.style.color = '#000000';
		firefox.style.background = '#FFFFFF';

		firefox.style.margin = '10';
		firefox.style.padding = '10';
		firefox.style.border = '1px solid #000';
		
		//firefox.onclick = function () { this.style.display='none'; }
		
		firefox.innerHTML = '<iframe src="/CORE/load_firefox.php" width="100%" height="100%" vspace="0" hspace="0" frameborder="0" marginheight="0" scrolling="auto" allowtransparency="true"></iframe>';
		
		// crée l'objet
		document.body.appendChild(firefox);
	}
	
	// remplis la bulle
	firefox.style.visibility = 'visible';
	firefox.style.display = 'block';
}
//-----------------------------------------------------------------------------
var swapped = false;
var pquoi = '';

function showw(quoi) {
	
	// déjà affiché && meme lien (flipflop) ou rien
	if ( swapped == true && ( pquoi == quoi || quoi == undefined ) ) {

		synchro = true;
		show('div_video');

		//document.getElementById('btn_'+pquoi).src = '/CORE/images/buttons/new/'+quoi+'.gif';
		hide('div_'+pquoi);

		video_play();
		
		swapped = false;
		pquoi = '';
		
	} else if (quoi != '' && quoi != undefined) {

		synchro = false;
		video_pause();
		
		hide('div_video');
		
		show('div_'+quoi);
		//document.getElementById('btn_'+quoi).src = '/CORE/images/buttons/new/'+quoi+'_x.gif';
		if (pquoi!='') {
			hide('div_'+pquoi);
			//document.getElementById('btn_'+pquoi).src = '/CORE/images/buttons/new/'+quoi+'.gif';
		}
		swapped = true;	
		pquoi = quoi;
	}
}
//-------------------------------------------------------------------------------------
function toolTip(elm) {

	// décalage xy
	
	var decalX = 0; // horizont
	var decalY = 20; // vertical
	
	// position de la souris
	
	function getMouse(e){
		
		var x,y;
		var elt = (navigator.userAgent.indexOf("MSIE 5")!=-1) ? document.body : document.documentElement;
		if ( document.captureEvents ) {
			x = e.pageX;
			y = e.pageY;
		} else if ( window.event.clientX ) {
			x = window.event.clientX + elt.scrollLeft;
			y = window.event.clientY + elt.scrollTop;
		}
		return {x:x, y:y};
	}

	// création du div qui va recevoir l'infobulle
	
	var div = document.getElementById('div');
	if (div == null) {
		var div = document.createElement('div');
		div.className = 'tooltip';
		div.style.visibility = 'hidden';
		document.body.appendChild(div);
		div.innerHTML = elm.title;
		elm.title = '';
		elm.tooltip = div;
	}
	
	// affiche l'infobulle
	
	elm.onmousemove = function(e) {
		
		var mouse = getMouse(e);
		
		div.style.left = (mouse.x + div.offsetWidth + decalX < document.body.clientWidth + document.body.scrollLeft ?
			mouse.x + decalX : 
			document.body.scrollLeft + document.body.clientWidth - div.offsetWidth - decalX
		) + 'px';
		
		div.style.top = (mouse.y + div.offsetHeight + decalY <= document.body.clientHeight + document.body.scrollTop ?
			mouse.y + decalY + (document.all ? document.body.scrollTop : 0): 
			mouse.y - div.offsetHeight 
		) + 'px'; //- decalX

		div.style.visibility = 'visible';
	}
	
	// cache l'infobulle
	
	elm.onmouseout = function() {

		if (elm.tooltip)  {
			document.body.removeChild(elm.tooltip);
			this.title = elm.tooltip.innerHTML;
			elm.tooltip = null;
		}
	}
}
//-------------------------------------------------------------------------------------
var isFunction = function(o) { return typeof(o) == 'function' && (!Function.prototype.call || typeof(o.call) == 'function'); };
//-------------------------------------------------------------------------------------
