/*
 * Copyright (C) 2006 Nicolas Vervelle,  The Jmol Development Team
 *
 * Contact: nico@jmol.org, jmol-developers@lists.sf.net
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 */

/* Jaime Prilusky 2008 -- moved to Proteopedia/Support.js */
// function newAppletWindow(id) {
//   var sm = ""  +Math.random(); 
//   sm = sm.substring(2,10);
//   var url  = "/wiki/extensions/Jmol/JmolPopup.html";
//   if (id != undefined) { url = url + "?id=" + id + "&";}
//   var name = "jmol_" + sm;
//   var options = "menubar=yes,resizable=1,scrollbars,alwaysRaised,width=600,height=600,left=50";
//   var newwindow = window.open(url,name,options);
//   if (window.focus) {newwindow.focus()}
//   return false;
// }

function jmolWikiPopupWindow(extensionPath, windowTitle, windowSize, windowLeft, windowTop, windowCode) {
  var windowWidth = parseInt(windowSize) + 15;
  var windowHeight = parseInt(windowSize) + 15;
  var opt = "width=" + windowWidth + "," +
            "height=" + windowHeight + "," +
            "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1," +
            "left=" + windowLeft + ",top=" + windowTop ;
  var s =
    "<html><head>\n" +
    "<script language='Javascript' type='text/javascript' src='" + extensionPath + "/Jmol.js'></script>\n" +
    "<title>" + windowTitle + "</title>\n" +
    "</head><body>" +
    "<script language='Javascript' type='text/javascript'>\n" + windowCode + "\n</script>\n" +
    "</body></html>";
    
  var w = open("", windowTitle, opt);
  w.document.open();
  w.document.write(s);
  w.document.close();
  w.focus();
}

/* Eran Hodis Feb 2009 -- moved to Proteopedia/Support.js */
/* function for Consurf chain buttons in Structure Box */
// function ConsurfChainButton(elementClicked) {
// 	// get the suffix of the Jmol applet on which we want to act by checking the target suffix added onto a child Jmol button's id
// 	//var targetSuffix = String(elementClicked);
// 	var strStart = elementClicked.lastIndexOf("_");
// 	var targetSuffix = elementClicked.slice(strStart + 1);
// 	var chainLetter = elementClicked.slice(0,strStart);
// 	strStart = chainLetter.lastIndexOf("_");
// 	chainLetter = chainLetter.slice(strStart + 1);
// 	var PDBid = elementClicked.slice(0,strStart);
// 	strStart = PDBid.lastIndexOf("_");
// 	PDBid = PDBid.slice(strStart + 1);
// 	var displayOn  = chainLetter + ' [x]';
// 	var displayOff = chainLetter + ' [  ]';
// 	if (document.getElementById(elementClicked).value==displayOn) {
// 		document.getElementById(elementClicked).value=displayOff;
// 	} else {
// 		document.getElementById(elementClicked).value=displayOn;
// 	}
// 	
// 	var jmolScriptLoadPDB = "if (loadedfileprev != \""+PDBid.toUpperCase()+"\"); set refreshing false; load /cgi-bin/getpdbz?"+PDBid+"; loadedfileprev = \""+PDBid.toUpperCase()+"\"; reloadfile=true; endif;";
// 	var jmolScriptColorConsurf = "select protein; define ~consurf_to_do selected; consurf_initial_scene = true; script \"/wiki/ConSurf/" + PDBid.slice(1,3) + "/" + PDBid + "_consurf.spt\"; set refreshing true;";
// 	
// 	// make sure the right PDB file is loaded
// 	jmolScript(jmolScriptLoadPDB,targetSuffix);
// 	// make sure the right coloring and representations are used
// 	jmolScript(jmolScriptColorConsurf,targetSuffix);
// 	
// 	// set the chains to match their displayed status on their Consurf buttons
// 	var Buttons = document.getElementById(elementClicked).parentNode.parentNode.parentNode.getElementsByTagName("input");
// 	for (var i = 0; i < Buttons.length; i++) {
// 		strStart = Buttons[i].value.lastIndexOf(" [");
// 		chainLetter = Buttons[i].value.slice(0,strStart);
// 		if (Buttons[i].value.lastIndexOf("[x]") == -1) {
// 			jmolScriptSetChain = "select :"+chainLetter+" and protein; spacefill off;color translucent -1; consurf_"+chainLetter+" = 1;"
// 			jmolScript(jmolScriptSetChain,targetSuffix);
// 		} else {
// 			jmolScriptSetChain = "select :"+chainLetter+" and protein; spacefill on; color opaque;consurf_"+chainLetter+" = 0;";
// 			jmolScript(jmolScriptSetChain,targetSuffix);
// 		}
// 	}
// }


function setupCheckboxShiftClick() {
  return;
// Solution by Angel Herraez to resume checkbox functionality
// JP 2009
}

