function MM_openBrWindow(theURL, features) {
	if (!features) {
		features = 'width=720,height=550';
	}
	window.open('/static/'+theURL, 'Static', features);
}
 
/*Lien vers la poup text Riche*/
function openPopupTextRich(pid, tpl, cid) {
	strUrl = 'index_popup.php?tpl='+tpl;
	if (pid) {
		strUrl += '&pid='+pid;
	}
	if (cid) {
		strUrl += '&cid='+cid;
	}
	window.open(strUrl, 'TexteRiche', 'height=400,width=610,scrollbars=yes');
}
 
//Fonction générique douverture de la popup inscription
//utlisé dans commun_jeu_multi.tpl, jeux_form.tpl
function openInscription(pid, spf, spso, spss, spsb, cid, cv, referer) {
	var r = 1;
	window.open('/index_popup.php?tpl=222&mess=7&pid='+pid+'&spf='+spf+'&spso='+spso+'&spss='+spss+'&spsb='+spsb+'&cid='+cid+'&cv='+cv+'&postgame=1&gcid='+cid+'&referer='+referer, "Confirmation", "width=200,height=200");
}
function openPopupInscription(pid, spf, spso, spss, spsb, cid, cv, referer) {
	switch (referer) {
		case 'jeux_form':
		//window.open('index_popup.php?tpl=15&pid='+pid+'&postgame=1&gcid='+cid, 'Inscription','height=360,width=490');
		window.opener.location = 'index.php?tpl=10&pid='+pid+'&postgame=1&gcid='+cid+'&init=1';
		break;
		default:
		window.opener.top.location = 'index.php?tpl=10&pid='+pid+'&spf='+spf+'&spso='+spso+'&spss='+spss+'&spsb='+spsb+'&cid='+cid+'&cv='+cv+'&init=1';
		break;
		 
	}
	window.close();
}
/*
var emag;

function openEmag() {
*/
/*
	if (exists && emag) {
		emag = window.open("/lib/emag.php", 'emag', 'height=586,width=798,scrollbars=no');
	}
*/
/*	
	if (!emag || emag.closed) {
		emag = window.open("/lib/emag.php", 'emag', 'height=592,width=780,scrollbars=no');
	} else {
		emag.focus();
	}
}
function openEmagAuthentification() {

	if (!emag || emag.closed) {
		emag = window.open("/lib/emag.php?etape=3", 'emag', 'height=592,width=780,scrollbars=no');
	} else {
		emag.focus();
	}
}
function openEmagChoixPapier() {
	if (!emag || emag.closed) {
		emag = window.open("/lib/emag.php?etape=2&msg=8", 'emag', 'height=592,width=780,scrollbars=no');
	} else {
		emag.focus();
	}
}
*/
	function connectEmag(id) {		
		var url;
		url = '/lib/emag.php?iframe=1';
		if (typeof window.ActiveXObject != 'undefined' ) {
			xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
			xmlDoc.onreadystatechange = readEmag;
		} else {
	        xmlDoc = new XMLHttpRequest();
       	    xmlDoc.onload = readEmag;
        }		
		xmlDoc.open( "GET", url, true );		
        xmlDoc.send(null);
	}

	function readEmag(){
		if (xmlDoc.readyState == 4) {
        	// only if "OK"
			if (xmlDoc.status == 200) {
				window.open(xmlDoc.responseText);				
            } else {
                alert("There was a problem retrieving the data:\n" + xmlDoc.statusText);
           }
		}	
}	
function openPopupTextRichSite(pid,tpl,cid, height, width, scroll, urlSite) {
	strUrl='http://'+urlSite+'/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);
}


	/**
	 * Affiche une div à la position demandée
	 */

	function showPopupWithPosition(divId, iTop, iLeft) {
		
		var popupStyle = document.getElementById(divId).style;
		
		if (popupStyle.display == 'none') {
			popupStyle.left = iLeft  + "px";
			popupStyle.top = iTop + "px";
			popupStyle.display = 'block';
		}
	}

	/**
	* Fonction permettant d'inclure un script js dans une page
	*/
	function includeScript(fileName,destDivId) {
		if (document.getElementsByTagName) {
			//création du Script d'appel cyberestat
			Script = document.createElement("script");
			Script.language = "JavaScript";
			Script.src = fileName;
			Script.defer = "defer";
			destDiv = document.getElementById(destDivId);
			if (destDiv) {
				destDiv.replaceChild(Script,destDiv.firstChild);
			}
		}
	}
	
	/**
	* Fonction permettant d'inclure un script js dans une page
	*/
	
	function callCyberestat(client,section,rubrique){
		try{
			//pour tester si les variables sont définies, sinon on va dans le catch
			var toto1=CM_RUBRIQUE;
			var toto2=CM_CLIENT;
			var toto3=CM_SECTION1;

			if(CM_RUBRIQUE && CM_CLIENT && CM_SECTION1){
					if(client!=''){
						CM_CLIENT = client;
					}
					if(section!=''){ 
						CM_SECTION1 = section;
					}if(rubrique!=''){
						CM_RUBRIQUE = rubrique;
					}
					cyberurl='http://js.cybermonitor.com/'+CM_CLIENT+'.js'
					includeScript(cyberurl,'divcyberestat');
				}
				else{
					alert("Il n'y a pas de tag cyberestat sur cette page, l'appel ne peut pas fonctionner");
				}
			}
		
		catch(e){
			
		}
	
	}