// Copyright Hippocampe 2001
browserVer = parseInt(navigator.appVersion);
browserName = navigator.appName;
browser = 0;
url = "" + document.location;
var printAll=false;
// Netscape ou IE
if ((browserName == 'Netscape') && (browserVer >= 2) && (browserVer != 5))
	browser = 1;
else
	browser = 2;

function addHeader(){
	var buffer =null;
	buffer = "<html>\r\n";
	buffer += "<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'\r\n";
	buffer += "'http://www.w3.org/TR/html4/strict.dtd'>\r\n";
	buffer += "		<head>\r\n";
    buffer += "			<title>Impression</title>\r\n";
    buffer += "			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>\r\n";
    buffer += "			<meta name='robots' content='index,follow'>\r\n";
    buffer += "			<meta http-equiv='Expires' content='0'>\r\n";
    buffer += "		 	<meta http-equiv='Pragma' content='no-cache'>\r\n";
    buffer += "			<meta http-equiv='Cache-Control' content='no-cache'>\r\n";
    buffer += "			<link rel=stylesheet type='text/css' href='../configuration/css/ie_site.css' title='Feuille de style du site'>\r\n";
    buffer += "		</head>\r\n";
	buffer += "		<body bgcolor='#ffffff' style='background-color: white;'>\r\n";
	return buffer;
}

function addFooter(){
	var buffer = null;
	buffer = "		</body>\r\n";
	buffer += "</html>\r\n";
	return buffer;
}

function imprime(){
	var bufferHtml = null;
	
	//if (browser==1)
	//	window.print();
	//else {
    	bufferHtml = addHeader();
		if (printAll)
			bufferHtml += document.myForm.hiddenContenu.value+"\r\n";
		else
	    	bufferHtml += document.getElementById('content').innerHTML+"\r\n";
    	bufferHtml += addFooter();
    	var win = open('', 'plateform_preview')
    	if (win) {
            win.document.open();
            win.moveTo(-1000, -1000);
            win.resizeTo(600, 400);
            
            win.document.write(bufferHtml);
            win.document.close();
            
            win.focus();
            win.print();
            win.close();
        }
	//}
}


/**
 * Ouvre la popup url
 *
 * @param url de la page
 */
// si x==-1 et y==-1 alors centrage par rapport à l'écran
var wPopWindow 				= null; // Popup
function windowOpen(urlPage,x,y,w,h) {
	if (wPopWindow && !wPopWindow.closed) {
		wPopWindow.close();
		wPopWindow = null;
	}
   	if (x==-1) x = (screen.width / 2) - (w / 2);
   	if (y==-1) y = (screen.height / 2) - (h / 2);
   	wPopWindow = window.open(urlPage,'wPopWindow','width=' + w + ',height=' + h + ',left=' + x + ',top=' + y + ',resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=NO');
   	wPopWindow.focus();
   	return false;
}
/**
 * Ouvre la popup url
 *
 * @param url de la page
 */
// si x==-1 et y==-1 alors centrage par rapport à l'écran
function windowOpenFixed(urlPage,x,y,w,h) {
	if (wPopWindow && !wPopWindow.closed) {
		wPopWindow.close();
		wPopWindow = null;
	}
   	if (x==-1) x = (screen.width / 2) - (w / 2);
   	if (y==-1) y = (screen.height / 2) - (h / 2);
   	wPopWindow = window.open(urlPage,'wPopWindow','width=' + w + ',height=' + h + ',left=' + x + ',top=' + y + ',resizable=no,scrollbars=yes,toolbar=no,location=no,directories=no,status=no');
   	wPopWindow.focus();
   	return false;
}

// va a la page via la navigation interne (suiv-precedent ou combo)
function goToPage(iOrdrePage, sCmdPage){
	if (iOrdrePage && sCmdPage) {
		document.formPage.cmd_page.value	= sCmdPage;
		document.formPage.ordre_page.value = iOrdrePage;
		document.formPage.submit();
		return true;
	}
	return false;
}


	
/**
 * Set une valeur dans le champ caché specialCmd et envoit le formulaire
 *
 * @param <form>
 * @param sCmd
 */
function setValueInSpecialCmd(form, sCmd)
{
	form.specialCmd.value = sCmd;
	form.submit();
}



function moveDiv() {
	if (browser==1){
		x = document.getElementById('placeImg').offsetLeft;
		document.getElementById('MENUFOND').style.left = x;
		document.getElementById('MENU').style.left = x;
		if (document.getElementById('ENGRENAGE'))
			document.getElementById('ENGRENAGE').style.left = x;
		if (document.getElementById('ENGRENAGEFILLE'))
			document.getElementById('ENGRENAGEFILLE').style.left = x;
		if (document.getElementById('CONTENER'))
			document.getElementById('CONTENER').style.left = x;
		if (document.getElementById('CONTENERFILLE'))
			document.getElementById('CONTENERFILLE').style.left = x;
	}
}

function toggleOnOffP(idParagraph){
	if (idParagraph.length){
		var currentId = document.getElementById(idParagraph);
		if (currentId.style.display=='none')
			currentId.style.display = 'block';
		else
			currentId.style.display = 'none';
	}
	
	var nodes = document.getElementById('content').childNodes;
	for(var iCount = 0; iCount < nodes.length; iCount++) {
		if (browser==2) {
			if (nodes(iCount).nodeName == "P"){
				if (nodes(iCount).id.indexOf('paragraph_', 0)>-1 && nodes(iCount).id != idParagraph)
					nodes(iCount).style.display = 'none';
			}
		} else {
			if (nodes[iCount].nodeName == "P"){
				if (nodes[iCount].id.indexOf('paragraph_', 0)>-1 && nodes[iCount].id != idParagraph)
					nodes[iCount].style.display = 'none';
			}
			//alert(nodes[iCount].nodeName);
		}
	}
}