function _PopUpParam (iwidth, iheight, mb, rs, sb, st, tb) {
	var strProperties;
	if (screen ) {
		var iPosL = (screen.width-iwidth)/2;
		var iPosT = (screen.height-iheight)/2;
	} else {
		var iPosL = 100;
		var iPosT = 100;
	}
	if (navigator.appVersion.indexOf("MSIE") != -1 ) {
		iwidth = iwidth+26;
	}
	strProperties = "width=" + iwidth + ",height=" + iheight;
	strProperties += ",left=" + iPosL + ",top=" + iPosT + ",directories=0";
	strProperties += ",hotkeys=1,location=0,menubar=" + mb;
	strProperties += ",resizable=" + rs + ",scrollbars=" + sb;
	strProperties += ",status=" + st + ",titlebar=0,toolbar=" + tb;
	return strProperties;
}

function popupSimpleNoScroll(PageURL, strName, iwidth, iheight) {
	return window.open(PageURL, strName, _PopUpParam(iwidth, iheight, 0, 0, 0, 0, 0));
}

function popupSimple(PageURL, strName, iwidth, iheight) {
	return window.open(PageURL, strName, _PopUpParam(iwidth, iheight, 0, 0, 1, 1, 0));
}

function popupMenuSimple(PageURL, strName, iwidth, iheight) {
	return window.open(PageURL, strName, _PopUpParam(iwidth, iheight, 1, 0, 1, 1, 0));
}

function CheckWindow (obj) {
	if (obj && !obj.closed )
		obj.close();
}

function popupColor(obj, obj2) {

	args = obj;
	var arr = showModalDialog(libDir+"/form_tools/editor/popup_colorpicker.htm", args, "dialogWidth:430px; dialogHeight:270px; scroll:no; status:no; center:yes; help:no" );

	if (arr != null) {
		obj.value = arr.toUpperCase();
		obj2.style.backgroundColor = arr.toUpperCase();
		obj.focus();
	}
}

var editor;

function popupEditor(boxName, subfolder) {
	if (editor) {
		editor.close();
	}
	editor = window.open(libDir+"/form_tools/editor/dhtml_editor.php?boxName=" + boxName + "&subfolder=" + subfolder, 'popup_editor', 'width=700,height=500,toolbar=no,status=yes,resizable=yes,menubar=no,scrollbars=no');
}

function resizeInner(width, height) {
	if (window.innerWidth) {
		window.innerWidth = width;
		window.innerHeight = height;
	} else {
		width += 5;
		height += 30;
		resizeTo(width, height);
	}
}
/*Lien vers la poup*/
function openPopupVideo(cid, getTitle) {
	strUrl='/index_popup.php?1=1&tpl=108';
	if(cid){
		strUrl+='&cid='+cid;
	}
	if(getTitle){
		strUrl+='&getTitle=1';
	}
	window.open(strUrl, 'Vidéo','height=720,width=780');
}
/*Lien vers la galerie photo*/
function openPopupGallery(gallery_id2, gallery_id3, gallery_id4, type) {
	strUrl='/index_popup.php?tpl=135&from=js';

	if(gallery_id2){
		strUrl +='&gallery_id2='+gallery_id2;
	}
	if(gallery_id3){
		strUrl +='&gallery_id3='+gallery_id3;
	}
	if(gallery_id4){
		strUrl +='&gallery_id4='+gallery_id4;
	}
	if(type){
		strUrl +='&type='+type;
	}
	window.open(strUrl, 'Galerie','height=720,width=780');
}
/*Lien vers la poup*/
function openPopupEnsavoirPlus(cid, thePath) {
	strUrl= thePath+'/index_popup.php?tpl=124';
	if(cid){
		strUrl+='&cid='+cid;
	}
	window.open(strUrl, 'savoirplus','height=650,width=650,left=0,top=0,scrollbars=no');
}

function openNewPopup(cid) {
	strUrl= 'index_popup.php?tpl=184';
	if(cid){
		strUrl+='&cid='+cid;
	}
	window.open(strUrl, 'thePopUp','height=650,width=650,left=0,top=0,scrollbars=no');
}

function openPopupMosaique() {
	strUrl='index_popup.php?tpl=119&annee=2004';
	window.open(strUrl, 'Mosaique','height=730,width=796,scrollbars=yes');
}

function getFileExtension(strPath) {
	var strfileName, valPosition, strfileExtension
	valPosition = String(strPath).lastIndexOf('\\',0);
	strfileName = String(strPath).substr(valPosition+1);
	valPosition = strfileName.lastIndexOf('.');
	strfileExtension = strfileName.substr(valPosition+1);
	return strfileExtension;
}

/*Lien vers la poup*/
function openPopupRich(cid, largeur, hauteur, path) {
	var theLargeur, theHauteur, thePath;
	var nombre_args = arguments.length;
	if (nombre_args == 1)
	{
	theLargeur = 650;
	theHauteur = 650;
	thePath = "";
	}
	else if (nombre_args == 2)
	{
	theLargeur = largeur;
	theHauteur = 650;
	thePath = "";
	}
	else if (nombre_args == 3)
	{
	theLargeur = largeur;
	theHauteur = hauteur;
	thePath = "";
	}
	else if (nombre_args == 4)
	{
	theLargeur = largeur;
	theHauteur = hauteur;
	thePath = path;
	}
	strUrl= thePath + '/index_popup.php?tpl=124';
	if(cid){
		strUrl+='&cid='+cid;
	}
	window.open(strUrl, 'savoirplus','width='+theLargeur+',height='+theHauteur+',left=0,top=0,scrollbars=yes');
}

/*Lien vers la poup d'un contenu Son unique*/
function openPopupSonUnique(cid) {
	strUrl='index_popup.php?tpl=279';
	if(cid){
		strUrl+='&cid='+cid;
	}
	window.open(strUrl, 'Video','height=365,width=218');
}

/*Lien vers la poup text Riche*/
function openPopupTextRich(pid,tpl,cid, height, width, scroll) {
	strUrl='index_popup.php?tpl='+tpl;
	if(pid){
		strUrl+='&pid='+pid;
	}
	if(cid){
		strUrl+='&cid='+cid;
	}
	if(!height) height=400;
	if(!width) width=610;
	if(scroll){
		scroll='yes';
	}else{
		scroll='no';
	}
	window.open(strUrl, 'TexteRiche','height='+height+',width='+width+',scrollbars='+scroll);
}

function openPopupTextRichSlogo(pid,tpl,cid, height, width, scroll) {

	strUrl='index_popup.php?tpl='+tpl;
	if(pid){
		strUrl+='&pid='+pid;
	}
	if(cid){
		strUrl+='&cid='+cid;
	}
	if(!height) height=400;
	if(!width) width=610;
	if(scroll){
		scroll='yes';
	}else{
		scroll='no';
	}
	window.open(strUrl,'Riche' ,'height='+height+',width='+width+',scrollbars='+scroll);
}

function videoPlayer(contentId){
	if(sUrlBigPlayer){
		document.location = sUrlBigPlayer + '/#/' + contentId + "/" + sRequestURI;
	}
}

function videoPlayerWithParentContent(contentId, contentParentId){
	if(sUrlBigPlayer){
		document.location = sUrlBigPlayer + '/#/' + contentId + "/" + sRequestURI;
	}
}

function displayEpg(){
	document.getElementById('epg').style.zIndex='3';
	document.getElementById('flashContentEpg').style.zIndex='3';
}

function hideEpg(){
	document.getElementById('epg').style.zIndex='0';
	document.getElementById('flashContentEpg').style.zIndex='0';
}

// Variable Temp pour gerer les vidéo Media_player :
var isPlayerInfoSport = false;

function displayPlayer(){
	if(sUrlBigPlayer){
		if(sThematiqueListe != ''){
			document.location = sUrlBigPlayer + '/#/' + sThematiqueListe + '/' + sRequestURI;
		}else{
			document.location = sUrlBigPlayer + '/#/' + sRequestURI;
		}
	}
}


var BackupBackgroundImage;

function displayPlayerNoWrite(){
	if(sUrlBigPlayer){
		document.location = sUrlBigPlayer + '/#/' + sRequestURI;
	}
}

function hidePlayer(){


	// Affiche la page qui reste en dessous :
	//document.getElementById('zones').style.visibility="visible";
	document.getElementById('zones').style.display="block";
	// Change la couleur de fond :
	document.body.style.backgroundColor="";
	document.body.style.backgroundImage = BackupBackgroundImage;

	// Cas du player Info Sport
	if(isPlayerInfoSport){
		history.go(0);
	}else{

		// Mise a jour de la variable javascript pour distinguer le grandPlayer/petitPlayer
		//isFullPlayer = 0;

		if(document.getElementById("embed_playercontent_full")){
			document.getElementById("embed_playercontent_full").innerHTML = "";		
		}	
		
		//alert("YOYOYOYO fermeture du player");
		document.getElementById('player_video').zIndex='1';
		document.getElementById('player_video').style.width='20px';
		document.getElementById('player_video').style.height='auto';
		document.getElementById('player_video').style.marginLeft='960px';
		//document.getElementById('player_video').onclick=displayPlayer;
		document.getElementById('player_video').style.backgroundColor='#FFFFFF';
		document.getElementById('divPlayerVideo').style.display='none';
		document.getElementById('bt_player_video').style.display='block';
		showSelectTags();

		/*
		if (typeNavForFlash == "ie_6.0"){
			document.getElementById('bt_player_video').style.height = "800px";//
		}else{
			document.getElementById('bt_player_video').style.height = "100%";
		}*/
		
	}
}

function hideSelectTags(){
	iNbCombo = document.getElementsByTagName('select').length;
	for (i=0; i<iNbCombo; i++) {
		document.getElementsByTagName('select')[i].style.visibility = "hidden";
	}
}
function showSelectTags(){
	iNbCombo = document.getElementsByTagName('select').length;
	for (i=0; i<iNbCombo; i++) {
		document.getElementsByTagName('select')[i].style.visibility = "visible";
	}
}


function displayPubHome(){
	document.getElementById('publicite_home').style.left='658px';
	document.getElementById('publicite_home').style.top='190px';
	document.getElementById('publicite_home').style.width='300px';
	document.getElementById('publicite_home').style.height='250px';
	document.getElementById('publicite_home').style.display='block';
	//xajax_wwwplus_load_pub_home('publicite_home','pave');
	
	
	setTimeout("hidePubHome()",10000);
}

function hidePubHome(){
	document.getElementById('publicite_home').style.left='808px';
	document.getElementById('publicite_home').style.top='315px';
	document.getElementById('publicite_home').style.width='150px';
	document.getElementById('publicite_home').style.height='125px';
	//xajax_wwwplus_load_pub_home('publicite_home','vignette');
}

try {
	jQuery(document).ready(function(){
		onloadcall();
	});
} catch(err) {
	
}

function onloadcall(){
	// Lancement ajax pour Fiche Emission Programme et corriger le bug d'IE6
	if(typeof(lancer_premiere_emission)=='function'){
		lancer_premiere_emission();
	}

	if(typeof(InitAfficherComment_v2)=='function'){
		InitAfficherComment_v2();
	}

	if(typeof(changeNavNews)=='function'){
		changeNavNews();
	}

	if(typeof(InitAfficherComment)=='function'){
		InitAfficherComment();
	}

	if(typeof(initScrollLayer1)=='function'){
		initScrollLayer1();
	}

	if(typeof(videoExclu)=='function'){
		videoExclu(0);
	}

	if(typeof(initPageSerie)=='function'){
		initPageSerie();
	}

	if(typeof(initSportArticlesListe)=='function'){
		initSportArticlesListe();
	}

	if(typeof(initSportArticle)=='function'){
		initSportArticle();
	}

	if(typeof(initSportChangeComboJournee)=='function'){
		initSportChangeComboJournee();
	}
	
	if(typeof(initVitrineSecondaireLive)=='function'){
		initVitrineSecondaireLive();
	}
	
	if(typeof(initVitrineSecondaireNewsSport)=='function'){
		initVitrineSecondaireNewsSport();
	}
	//swfmenu.write('nav');
	/*if(document.getElementById('publicite_home')){
		displayPubHome();
	}*/
}

function goToLog(){
	//alert("Activation Du Panneau");
	showIndification();

	//Je masque le player + la pub + l'encart Pub:
	document.getElementById('embed_playercontent_full').innerHTML = '';
	document.getElementById('advertmessagecontent_full').innerHTML = '';
	document.getElementById('advertcontent_full').innerHTML = '';
	hideEmbedPlayer();

	//alert("Fermeture du player");
	closeVideoPlayer(); // Dans le fichier External-interface du rep flash/javascript
}



/**
 * This script contains embed functions for common plugins. This scripts are complety free to use for any purpose.
 */

function writeFlash(p) {
	writeEmbed(
		'D27CDB6E-AE6D-11cf-96B8-444553540000',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'application/x-shockwave-flash',
		p
	);
}

function writeShockWave(p) {
	writeEmbed(
	'166B1BCA-3F9C-11CF-8075-444553540000',
	'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0',
	'application/x-director',
		p
	);
}

function writeQuickTime(p) {
	writeEmbed(
		'02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
		'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',
		'video/quicktime',
		p
	);
}

function writeRealMedia(p) {
	writeEmbed(
		'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'audio/x-pn-realaudio-plugin',
		p
	);
}

function writeWindowsMedia(p) {
	p.url = p.src;
	writeEmbed(
		'6BF52A52-394A-11D3-B153-00C04F79FAA6',
		'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701',
		'application/x-mplayer2',
		p
	);
}

function writeEmbed(cls, cb, mt, p) {
	var h = '', n;

	h += '<object classid="clsid:' + cls + '" codebase="' + cb + '"';
	h += typeof(p.id) != "undefined" ? 'id="' + p.id + '"' : '';
	h += typeof(p.name) != "undefined" ? 'name="' + p.name + '"' : '';
	h += typeof(p.width) != "undefined" ? 'width="' + p.width + '"' : '';
	h += typeof(p.height) != "undefined" ? 'height="' + p.height + '"' : '';
	h += typeof(p.align) != "undefined" ? 'align="' + p.align + '"' : '';
	h += '>';

	for (n in p)
		h += '<param name="' + n + '" value="' + p[n] + '">';

	h += '<embed type="' + mt + '"';

	for (n in p)
		h += n + '="' + p[n] + '" ';

	h += '></embed></object>';

	document.write(h);
}

