var JmolPath="./"
document.writeln('<script src="' + JmolPath + 'Jmol.js" type="text/javascript"></script>')
var comunPath = "../_comun/"

	/*  By (re)setting these variables in the webpage before calling jmolApplet(), 
		a custom message can be provided (e.g. localized for user's language) when no Java is installed.
	*/
noJavaMsg = noJavaMsg2 = "Aqu&iacute; deber&iacute;a ir una miniaplicaci&oacute;n Java para mostrar los modelos moleculares.<br />\n"
+ "Si el uso de Java no est&aacute; permitido en el navegador, debes modificar la configuraci&oacute;n para activarlo.<br />\n"
+ "Si Java no est&aacute; instalado, visita <a href='http://www.java.com' target='_blank'>www.java.com</a><br />\n"
+ "Si no puedes usar la miniaplicaci&oacute;n, no podr&aacute;s ver los modelos."

function clickJ()
{	return "zap; set echo middle center; font echo 20; color echo yellow; "
	+ "echo Pulsa sobre un botón o | sobre un texto subrayado | en el panel de la derecha; "
}

function button(scrp,t)
{	if (!t) { t = "X" }
	jmolSetButtonCssClass("btnX")
	jmolButton(scrp,t)
	jmolSetButtonCssClass("")
}	// Fija ancho de botón X --si no, demasiado estrecho en IE--

function btn_V(molfile)
{	document.write('<button title="Varillas" style="padding:0;" onClick="jmolScript(\'load ' + molfile + '; wireframe 0.2; spacefill off;\');return false;"><img src="icono_v.gif" alt="Varillas" title="Varillas" width="25"></button>')
	// button('load ' + molfile + '; wireframe 0.2; spacefill off;', '/')
}	
function btn_BV(molfile)
{	document.write('<button title="Bolas y varillas" style="padding:0;" onClick="jmolScript(\'load ' + molfile + ';\');return false;"><img src="icono_bv.gif" alt="Bolas y varillas" title="Bolas y varillas" width="25"></button>')
	// button('load ' + molfile + '; ', 'o')
}	
function btn_E(molfile)
{	document.write('<button title="Esferas" style="padding:0;" onClick="jmolScript(\'load ' + molfile + '; spacefill 90%;\');return false;"><img src="icono_cp.gif" alt="Esferas" title="Esferas" width="25"></button>')
	// button('load ' + molfile + '; spacefill 90%;', 'O')
}	


function pie(pa,ps,indSecTx,indSecUrl) 
{	var tx = '<p><p><div align="center"><form><hr>'
	if ( pa!="" || ps!="" ) { 
		tx += '<table width=100%><tr><td align="left">'
		if (pa!="") { tx += '<a href="' + pa + '"><img src="' + comunPath + 'pag-ant.gif" width="75" height="23" border="0" title="Pág.anterior" alt="Pág.anterior"></a>' }
		tx += '</td><td align="right">'
		if (ps!="") { tx += '<a href="' + ps + '"><img src="' + comunPath + 'pag-sig.gif" width="75" height="23" border="0" title="Pág.siguiente" alt="Pág.siguiente"></a>' }
		tx += '</td></tr></table>'
	}
	document.writeln(tx)
	tx =''
	if (indSecTx) { tx += '<input type=button value="' + indSecTx + '" onClick="location.href=\'' + indSecUrl + '\'">' }
	tx += '<p><input type=button value="volver al índice" onClick="location.href=\'contents.htm\'">'
	tx += '<br><a href="javascript:void(abreUtils(1))">Utilidades</a>'
	tx += '<br><a href="javascript:void(abreUtils(2))">Esquemas de color</a>'
	tx += '<br><a href="javascript:void(abreUtils(4))">Manejo del ratón</a>'
	tx += '</form></div><hr class="hrInf" style="margin-top:-0.5em">'
	document.writeln(tx)
	document.close()
}

function abreUtils(k)
{	if (k==1) f= "_utiles.htm"		// diferente de model1j
	else if (k==2) f= "_colores.htm"		// diferente de model1j
	else if (k==3) f= comunPath + "color-elem.htm"
	else if (k==4) f= comunPath + "mouse.htm"
	var d1 = mideVentana(parent.modelo)		// diferente de model1j
	var d2 = mideVentana(parent.texto)
	var barras = self.screen.height-self.screen.availHeight
	vUtils = window.open(f, "utilidades", "resizable, scrollbars, width=" + d2[0] + ", height=" + (self.screen.availHeight-barras) + ", left=" + (d1[0]+4) + ", top=0. address=false" )
	vUtils.focus()
}

function mideVentana(vent)
{	if (!vent) vent=self
	var x, y
	if (vent.innerWidth)
	{	x = vent.innerWidth; y = vent.innerHeight;
	}
	else if (vent.document.documentElement && vent.document.documentElement.clientWidth) // IE6 en modo Estricto
	{	x = vent.document.documentElement.clientWidth; y = vent.document.documentElement.clientHeight;
	}
	else if (vent.document.body && vent.document.body.clientWidth)  // otros IE e IE6 en modo Quirks (por ej., sin declaración <!DOCTYPE HTML )
	{	x = vent.document.body.clientWidth; y = vent.document.body.clientHeight;
	}
	else { x=600; y=550 }
	return [x,y]
}



var scr_colorMacroMicro = "define temp selected; "
+ "select protein; color [xcbbe8a]; "
+ "select dna; color [xae00fe]; "
+ "select rna; color [xfd0162]; "
+ "select calcium, not (protein, nucleic, water); color [x6dfa36]; "
+ "select solvent; color [x3a79bc]; "
+ "select temp; "

var scr_colorStructure = "define temp selected; select protein; color structure; select temp; "

function scr_colorPolarity(k)
{	var tx =  "define temp selected; "
	tx += "select protein; color [xc8c8c8]; "	// .nonpolar
	tx += "select protein and polar; color [xff33ff]; "	// .polar
	if (k>2) tx	+= "select protein and backbone; color [xb000b0]; "	// .backbone
	if (k>3) 
	{	tx	+= "select protein and acidic and not backbone; color [xdd0000]; "
		tx	+= "select protein and basic and not backbone; color [x3366ff]; "
	}
	if (k>5) tx	+= "select protein and aromatic and not backbone; color [x007700]; "
	tx += "select temp; "
	return tx
}

var colorNt = "select a; color [x5050FF]; "
+ "select t; color [xE6E600]; "
+ "select g; color [x00C000]; "
+ "select c; color [xE00000]; "
+ "select u; color [xCC9900]; "
var scr_colorNt = "define temp selected; " + colorNt + "select temp; "
var scr_colorNtBb = "define temp selected; " + colorNt 
+ "select (dna and backbone); color [xAE00FE]; "
+ "select (rna and backbone); color [xFD0162]; "
+ "select temp; "

//= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
// COLOR KEYS	NOW READS FROM EXTERNAL CSS STYLE SHEET (WHICH HAS Jmol COLORS)
// Based on part of main-cpt.js, part of www.umass.edu/chime/prsswc template by Eric Martz
//= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

// wr_doc(to_write) is a utility function used below.
function wr_doc(to_write)
{	with(document) { open(); write(to_write); close(); }
}

//------------------------------------------------------------------
// key_top() begins a color key, key_bottom() completes it.
// These are called in color key functions such as chon() below.

function key_top()
{	wr_doc("<a href='javascript:void(abreUtils(3))'><span style='font-size:1.3em; font-weight:bold;'>")
}
function key_bottom()
{	wr_doc("</span>&nbsp;</a>")
}

//------------------------------------------------------------------
// The following functions each add one element to a color key.
// You can easily add new elements by copying and modifying one of these.

function C_key() { wr_doc("&nbsp;<span class='C'>C</span>") }
function H_key() { wr_doc("&nbsp;<span class='H'>H</span>") }
function N_key() { wr_doc("&nbsp;<span class='N'>N</span>") }
function O_key() { wr_doc("&nbsp;<span class='O'>O</span>") }
function S_key() { wr_doc("&nbsp;<span class='S'>S</span>") }
function P_key() { wr_doc("&nbsp;<span class='P'>P</span>") }
function Fe_key() { wr_doc("&nbsp;<span class='Fe'>Fe</span>") }

//------------------------------------------------------------------
// Here now are complete color key functions.  Each is named according
// to the elements included in the key it produces.

function chons_key()
{	key_top();
	C_key();
	H_key();
	O_key();
	N_key();
	S_key();
	key_bottom();
}

function chonspfe_key()
{	key_top();
	C_key();
	H_key();
	O_key();
	N_key();
	S_key();
	P_key();
	Fe_key();
	key_bottom();
}

/*  not used by now:

function chon_key()
{	key_top();
	C_key();
	H_key();
	O_key();
	N_key();
	key_bottom();
}

function chonp_key()
{	key_top();
	C_key();
	H_key();
	O_key();
	N_key();
	P_key();
	key_bottom();
}

function chonps_key()
{	key_top();
	C_key();
	H_key();
	O_key();
	N_key();
	P_key();
	S_key();
	key_bottom();
}

function chonfe_key()
{	key_top();
	C_key();
	H_key();
	O_key();
	N_key();
	Fe_key();
	key_bottom();
}

function con_key()
{	key_top();
	C_key();
	O_key();
	N_key();
	key_bottom();
}

function cons_key()
{	key_top();
	C_key();
	O_key();
	N_key();
	S_key();
	key_bottom();
}
*/
