function stopPropagation(evt) {
    if (window.event)
        window.event.cancelBubble = true;
    else
        evt.cancelBubble = true;
}

function openNemoWindow(windowName, spectrumURL, bgColor) {
	/* following line prevent propagation of the click, at least on internet explorer and safari */
	if (window.event) window.event.cancelBubble = true ;

	windowObject=window.open('', windowName,  'directories=no,height=600,location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no,width=800'); 
	
		if ((navigator.userAgent.indexOf("MSIE") != -1)  && 
		(parseInt(navigator.appVersion) > 3)) {
			if (windowObject.nemo) {
				windowObject.nemo.addJcamp(spectrumURL);
				windowObject.document.close();
				windowObject.focus();
				return;
			}
	}

	if (windowObject.getSpectraURL) spectrumURL+=","+windowObject.getSpectraURL();

	windowObject.document.write("<html><head><title>Spectrum window</title>");
	windowObject.document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/style.css\">");
	windowObject.document.write("<script language='JavaScript'>");
	windowObject.document.write("function getSpectraURL() {");
	windowObject.document.write("return '"+spectrumURL+"'");
	windowObject.document.write("}");
	windowObject.document.write("</scr");
	windowObject.document.write("ipt>");
	windowObject.document.write("</head>");
	windowObject.document.write("<body bgcolor='"+bgColor+"'>");
	windowObject.document.write("<applet code='org.cheminfo.applet.nemo.Nemo.class' archive='nemo.jar' codebase='/java/nemo/' width='100%' height='90%' name='nemo'>");
	windowObject.document.write("<param name='SOURCE_FILE' value='"+spectrumURL+"'>");
	windowObject.document.write("</applet>");

	windowObject.document.write("<form action='/cheminfo/servlet/org.cheminfo.applet.nemo.NemoServlet' method='post' target='_blank'");
	windowObject.document.write("	name='form' onSubmit='document.form.xmlString.value=document.nemo.getXML(); return true;'>");
	windowObject.document.write("Size: <input type='text' value=800 name='width' size=4> x <input type='text' value=600 name='height' size=4>");
	windowObject.document.write("<input type='hidden' value='' name='xmlString'>");
	windowObject.document.write("<input type='hidden' value='' name='options'>");
	windowObject.document.write("<input type='hidden' value='0' name='rotate'>");
	windowObject.document.write("<input type='hidden' value='72' name='resolution'>");
	windowObject.document.write("<input type='hidden' value='"+spectrumURL+"' name='url'>");
	windowObject.document.write("<select name='format' size='1'><option value='jpg'>jpeg</option><option selected value='png'>png</option></select>");

	windowObject.document.write("<input class=\"smallbutton\" type=\"submit\" name=\"submitButtonName\" onclick=\"form.rotate.value=0;form.resolution.value=72;form.options.value='nmrAcs,nmrTable';\" value=\"Get Image\">");
	windowObject.document.write("<input class=\"smallbutton\" type=\"submit\" name=\"submitButtonName\" onclick=\"form.rotate.value=1;form.width.value=1400;form.height.value=1000;form.resolution.value=100;form.options.value='print';\" value=\"Print A4\">");
	windowObject.document.write("<input class=\"smallbutton\" type=\"submit\" name=\"submitButtonName\" onclick=\"form.rotate.value=0;form.width.value=800;form.height.value=600;form.resolution.value=100;form.options.value='print,nmrAcs,nmrTable';\" value=\"Print Report\">");
	windowObject.document.write("<input class=\"smallbutton\" type=\"submit\" name=\"submitButtonName\" onclick=\"window.open(spectrumURL, windowName,  'directories=no,height=600,location=no,menubar=no,resizable=yes,scrollbars=no,status=no,toolbar=no,width=800');\" value=\"Download JDX\">");

	windowObject.document.write("<a href=\""+spectrumURL+"\" target=\"_blank\">Download</a>");

	windowObject.document.write("</form>");
	windowObject.document.write("</body></html>");

	windowObject.document.close();

	windowObject.focus();
}
