function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function updateObjVal(obj, txt_val)
{
	if (obj.value == '') obj.value = txt_val;
}

function logout()
{
	document.getElementById('logoutFrm').submit();
}

function chkLogin()
{
	login = document.getElementById('login').value.replace(/ /g, '');
	if (login == '')
	{
		alert('Veuillez entrer votre LOGIN');
		document.getElementById('login').value='';
		document.getElementById('login').focus();
		return;
	}
	pass = document.getElementById('pass').value.replace(/ /g, '');
	if (pass == '')
	{
		alert('Veuillez entrer votre MOT DE PASSE');
		document.getElementById('pass').value='';
		document.getElementById('pass').focus();
		return;
	}
	document.getElementById('loginFrm').submit();
}

function recherche()
{
	keyword = document.getElementById('keyword').value.replace(/ /g, '');
	if (keyword == '')
	{
		alert('Veuillez entrer un MOT CLE');
		document.getElementById('keyword').value='';
		document.getElementById('keyword').focus();
		return;
	}
	document.getElementById('searchFrm').submit();
}

function recherche_en()
{
	keyword = document.getElementById('keyword').value.replace(/ /g, '');
	if (keyword == '')
	{
		alert('Please enter a keyword');
		document.getElementById('keyword').value='';
		document.getElementById('keyword').focus();
		return;
	}
	document.getElementById('searchFrm').submit();
}

function popURL(nom)
{
	var screen_width = screen.width;
	var screen_height = screen.height;

 // Set the URL to the right hostname -- DH, 4 August 2011 --
 var hostUrl;
 var myloc = window.location.hostname;
 if (myloc.match(/localhost/i)!=null) hostUrl = 'http://localhost/';
 else if (myloc.match(/wwwtest/i)!=null) hostUrl = 'http://wwwtest.lri.fr/';
 else hostUrl = 'http://www.lri.fr/';

	switch (nom)
	{
		case 'Webmail':
			url = 'https://www.lri.fr/webmail/';
			break;
		case 'Webmail-ng':
		case 'WebmailNG':
			url = 'https://www.lri.fr/webmail/';
			break;
		case 'Reser':
			url = hostUrl + 'Reservation/index.php';
//			url = 'http://www.lri.fr/Reservation/index.php';
			break;
		case 'VieLabo':
			url = hostUrl + 'Vie_labo/index.php';
//			url = 'http://www.lri.fr/Vie_labo/index.php';
			break;
		case 'Bibliotheque':
			url = 'http://pc-biblio2.lri.fr/';
			break;
		case 'DocAdmin':
			url = hostUrl + 'doc/admin/index.php';
//			url = 'http://www.lri.fr/doc/admin/index.php';
			break;
		case 'Support':
			url = hostUrl + 'Support/index.php';
//			url = 'http://www.lri.fr/Support/index.php';
			break;
		case 'Valorisation':
			url = hostUrl + 'Valorisation/';
//			url = 'http://www.lri.fr/Valorisation/';
			break;
		case 'Appels_projets':
			url = hostUrl + 'Appels_projets/index.php';
//			url = 'http://www.lri.fr/Appels_projets/index.php';
			break;
	}

	//	window.open(url, nom, 'scrollbars=yes ,width='+screen_width+', height='+screen_height+', top=0, left=0');
	window.open(url, nom);
}

function tinymceEditor()
{
	tinyMCE.init({
		theme_advanced_styles : "Text 9px=text09; Text 9px bold=text09b; Text 10px=text10; Text 10px bold=text10b; Text 11px=text11; Text 11px bold=text11b; Text 12px=text12; Text 12px bold=text12b; White 10px=text10white; White 10px bold=text10bwhite; Title White 10px=title; Link=lnk",
		plugins : 'style,layer,table,advlink,save,advhr,advimage,advlink,emotions,insertdatetime,preview,media,searchreplace,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras',
		theme_advanced_buttons3_add_before : "tablecontrols",
		external_image_list_url : "utilities/image_list.js",
		content_css : "utilities/stylesheet.cms.css",
		theme_advanced_disable : "formatselect",
		mode : 'textareas',
		languages : 'fr',
		theme : 'advanced',
		debug : false
	});
}

