/**
 * Extracted from JChem sample application: JChemWebServices/tomcat/webapps/ROOT/ajax/js/view.js
 */
var JMarvin = {
	getSketch: function(mId, mWidth, mHeight, molecule, detach) {
		var html = '';

		if (molecule == null) {
			molecule = (Logic.appletMolFormat == 'sdf' || Logic.appletMolFormat == 'rdf' || Logic.appletMolFormat == 'mol' ? 
				Logic.molecules[mId].ws.replace(/\n/g, '\\n') : Logic.molecules[mId].ws);
		}

		if (navigator.appName == 'Microsoft Internet Explorer') {
	    	html = '<object '+(mId == null ? '' : 'id="'+mId+'" ') +
				'codeBase="http://java.sun.com/update/1.6.0/jinstall-6u14-windows-i586.cab#Version=1,5,0,0" ' +
				'height="'+mHeight+'" width="'+mWidth+'" ' +
				'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93">' + 
				'<param value="' + Config.marvinPath + '" name="codebase" />' + 
				'<param value="jmarvin.jar" name="archive" />' + 
				'<param value="chemaxon/marvin/applet/JMSketch" name="code" />' +
				'<param value="true" name="scriptable" />' +
				'<param value=\''+molecule+'\' name="mol" />' +
				'<param value="\\" name="escapeChar" />' +
				'<param value="true" name="legacy_lifecycle" />' +
				'<param value="false" name="buttonmenubar" />';
			if (detach != null) {
				html += '<param value="'+(detach == true ? 'show' : 'hide')+'" name="detach" />'+
						'<param value="false" name="undetachByX" />';
			}
			html += '</object>';
		} else {
		    html = '<embed '+(mId == null ? '' : 'id="'+mId+'" ') +
				'width="'+mWidth+'" height="'+mHeight+'" ' +
				'mol=\''+molecule+'\' escapeChar="\\" buttonmenubar="false" code="chemaxon/marvin/applet/JMSketch" legacy_lifecycle="true" ' +
				'archive="jmarvin.jar" codebase="' + Config.marvinPath + '" mayscript="true" ' +
				'pluginspage="http://java.sun.com/javase/downloads/index.jsp" type="application/x-java-applet;version=1.5" ';
			if (detach != null) {
				html += 'detach="'+(detach == true ? 'show' : 'hide')+'" undetachbyx="false" ';
			}
			html += '/>';
		}
		return html;
	}
}

