// pop-up function

var newWin = null;

function closeWin()
{
	if (newWin != null)
	{
		if(!newWin.closed)
			newWin.close();
	}
}


function popUp(strURL,strType,strWidth,strHeight)
{
	closeWin();
	
	var strOptions="";
	if (strType=="console") 
		strOptions="resizable,height="+strHeight+",width="+strWidth;

	if (strType=="fixed") 
		strOptions="status,height="+strHeight+",width="+strWidth;

	if (strType=="elastic") 
		strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;

	if (strType=="scroll") 
		strOptions="scrollbars,resizable,height="+strHeight+",width="+strWidth;

	newWin = window.open(strURL, 'newWin', strOptions);

	newWin.focus();
}

function buildMail(strAddress, strUrl, strClass,strNom)
{
	
	if(strNom == undefined)
	document.write('<a class="' + strClass + '" hre' + 'f="mai' + 'lto:' + strAddress +'@' + strUrl + '">' + strAddress +'@' + strUrl +'</a>') ;
	else
	document.write('<a class="' + strClass + '" hre' + 'f="mai' + 'lto:' + strAddress +'@' + strUrl + '">' + strNom +'</a>') ;
}

/*Fonction qui permet d'imprimer une page
IL faut bien indiquer dans le main le "<!-- STARTPAGEPRINT -->" et le "<!-- ENDPAGEPRINT -->"
autour du contenu */
function doPrint()
{
	var startPrintMark = "<!-- STARTPAGEPRINT -->" ;
	var endPrintMark = "<!-- ENDPAGEPRINT -->" ;
	var startPrintMark_icone = "<!-- STARTPAGEPRINT_ICONE -->" ;
	var endPrintMark_icone = "<!-- ENDPAGEPRINT_ICONE -->" ;
	var startPrintMark_theme = "<!-- STARTPAGEPRINT_THEME --><!-- " ;
	var endPrintMark_theme = " --><!-- ENDPAGEPRINT_THEME -->" ;
	var startPrintMark_nom_biblio = "<!-- STARTPAGEPRINT_NOM_BIBLIO --><!-- " ;
	var endPrintMark_nom_biblio = " --><!-- ENDPAGEPRINT_NOM_BIBLIO -->" ;

	//Récupération du theme
	var theme = document.body.innerHTML ;
	theme = theme.substr(theme.indexOf(startPrintMark_theme) + startPrintMark_theme.length) ;
	theme = theme.substr(0,theme.indexOf(endPrintMark_theme)) ;
	
	//Récupération du nom de la bibliothèque
	var nomBiblio = document.body.innerHTML ;
	nomBiblio = nomBiblio.substr(nomBiblio.indexOf(startPrintMark_nom_biblio) + startPrintMark_nom_biblio.length) ;
	nomBiblio = nomBiblio.substr(0,nomBiblio.indexOf(endPrintMark_nom_biblio)) ;
	
	
	
	var source = document.body.innerHTML ;
	var sourceSuite = document.body.innerHTML ;
	source = source.substr(source.indexOf(startPrintMark) + startPrintMark.length) ;
	source = source.substr(0,source.indexOf(startPrintMark_icone)) ;
	sourceSuite = sourceSuite.substr(sourceSuite.indexOf(endPrintMark_icone) + endPrintMark_icone.length) ;
	sourceSuite = sourceSuite.substr(0, sourceSuite.indexOf(endPrintMark)) ;
	
	source = source + sourceSuite ;


	var win = window.open("",'',"height=500,width=500,status=0, scrollbars=1,toolbar=0,menubar=0,location=0, resizable=1;");

	win.document.open();
	win.document.write('<html><head><title>Print</title><LINK href="/template/themes/');
	win.document.write(theme);
	win.document.write('/style/stylesPrint.css" rel="stylesheet"></head>');
	win.document.write('<body">') ;
        win.document.write('<table width=470 cellpadding=5 cellspacing=5 border=0">') ;
        win.document.write('<tr><td height=71><img src="/template/image/logo.jpg">');
        win.document.write('&nbsp;&nbsp;<img src="/template/image/print.gif" onclick="window.print();" style="cursor:hand"><hr color=#000000 width=450></td></tr>') ;
	win.document.write(source) ;
        win.document.write('</table>') ;

        win.document.write('</body></html>') ;
	win.document.close();
}

