/*
 * menuExpandable.js - implements an expandable menu based on a HTML list
 * Author: Dave Lindquist (dave@gazingus.org)
 * Modified: Richard Bradley @ Perceptive Instruments to add IsOpen boolean
 * 01/08/03  for stating which menus are initialised as open from start.
 */

if (!document.getElementById)
    document.getElementById = function() { return null; }

function initializeMenu(menuId, actuatorId, isOpen) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);

    if (menu == null || actuator == null) return;

	if(isOpen) {
	  actuator.parentNode.style.listStyleImage = "url(/img/minus.gif)";
	  menu.style.display = "block";
	} else {
      actuator.parentNode.style.listStyleImage = "url(/img/plus.gif)";
	}
    actuator.onclick = function() {
        var display = menu.style.display;
        this.parentNode.style.listStyleImage =
            (display == "block") ? "url(/img/plus.gif)" : "url(/img/minus.gif)";
        menu.style.listStyleImage = "url(/img/square.gif)";
        menu.style.display = (display == "block") ? "none" : "block";

        return false;
    }
}

/* The following function opens the request further info window */

function requestForm (url) {
  blankWin = window.open(url,'_blank','resizable=1,width=330,height=465,left=200,top=100,screenX=200,screenY=100');
}

function requestdemo (url) {
  blankWin = window.open(url,'_blank','resizable=1,scrollbars=1,width=330,height=670,left=420,top=20,screenX=420,screenY=20'); 
}

function flashwindow (url) {
  blankWin = window.open(url,'_blank','resizable=1,width=730,height=590,left=70,top=70,screenX=70,screenY=70'); 
}

function imagewindow (src, pagetitle) {
  var w = window.open('','_blank','toolbar=no,resizable=yes,scrollbars=yes');
  with (w.document) {
    open();
	writeln('<?xml version="1.0" encoding="iso-8859-1"?>');
    writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
	writeln('<html xmlns="http://www.w3.org/1999/xhtml">');
    writeln('<head><title>' + pagetitle + '</title>');
	writeln('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />');
	writeln('<link href="/pi.css" rel="stylesheet" type="text/css" /></head>');
    writeln('<body style="margin: 10px; text-align: center;">');
	writeln('<a href="#" onclick="window.close();"><strong>Close window</strong></a><br /><br />');
    writeln('<img src="' + src + '"><br />');
    writeln('<br /><a href="#" onclick="window.close();"><strong>Close window</strong></a>');
    writeln('</body></html>');
    close();
  }
}

function imagewindow_fr (src, pagetitle) {
  var w = window.open('','_blank','toolbar=no,resizable=yes,scrollbars=yes');
  with (w.document) {
    open();
	writeln('<?xml version="1.0" encoding="iso-8859-1"?>');
    writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
	writeln('<html xmlns="http://www.w3.org/1999/xhtml">');
    writeln('<head><title>' + pagetitle + '</title>');
	writeln('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />');
	writeln('<link href="/pi.css" rel="stylesheet" type="text/css" /></head>');
    writeln('<body style="margin: 10px; text-align: center;">');
	writeln('<a href="#" onclick="window.close();"><strong>Fermer fenêtre</strong></a><br /><br />');
    writeln('<img src="' + src + '"><br />');
    writeln('<br /><a href="#" onclick="window.close();"><strong>Fermer fenêtre</strong></a>');
    writeln('</body></html>');
    close();
  }
}

function stripblanks(field) {
var result = "";
var c = 0;
for (i=0; i<field.length; i++) {
  if (field.charAt(i) != " " || c > 0) {
    result += field.charAt(i);
    if (field.charAt(i) != " ") c = result.length;
    }
  }
return result.substr(0,c);
}

function validfield(field) {
field = stripBlanks(field);
if (field == '') return false;
return true;
}