// 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)
{
	document.write('<a hre' + 'f="mai' + 'lto:' + strAddress +'@' + strUrl + '">' + strAddress +'@' + strUrl +'</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(theme)
{
	var startPrintMark = "<!-- STARTPAGEPRINT -->" ;
	var endPrintMark = "<!-- ENDPAGEPRINT -->" ;
	var startPrintMark_icone = "<!-- STARTPAGEPRINT_ICONE -->" ;
	var endPrintMark_icone = "<!-- ENDPAGEPRINT_ICONE -->" ;


	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 startPrintMarkReservation = "<!-- STARTPAGEPRINT_RESERVATION -->" ;
	var endPrintMarkReservation = "<!-- ENDPAGEPRINT_RESERVATION -->" ;

	sourceSuite = source ;


	if(source.indexOf(startPrintMarkReservation) > -1){
	source = source.substr(0, source.indexOf(startPrintMarkReservation)) ;
	sourceSuite = sourceSuite.substr(sourceSuite.indexOf(endPrintMarkReservation) + endPrintMarkReservation.length) ;
	}
	else
	{
	sourceSuite = "";
	}

	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/styles.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=90 background="/template/themes/');
        win.document.write(theme);
        win.document.write('/image/logoPrint.gif" align=right valign=bottom><br><br><br><img src="/template/image/print.gif" onclick="window.print();" style="cursor:hand"></td></tr>') ;
	win.document.write(source) ;

        win.document.write('</table>') ;

        win.document.write('</body></html>') ;
	win.document.close();
}
