/*
 * workbench.js -- RCSB PDB Workbench Widget
 * Maintained by the RCSB PDB (Version 0709.1)
 *
 * Workbench Widget by the RCSB PDB is licensed under a 
 * Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.
 * <http://creativecommons.org/licenses/by-nc-sa/3.0/us/>
 * 
 */

var fontStyle = 'font-family:verdana,arial,helvetica,sans-serif;font-size:12px;text-align:center;';
var isMSIE = /*@cc_on!@*/false;

function wb_Submit() {
	var ok = wb_checkWorkbenchInput();
	if ( ok ) {
		wb_redirectPage();
	 }
	 return false;
}
function wb_checkWorkbenchInput(){
	if ( document.getElementById('workbenchAction').value == '' ) {
		alert('Please select a comparison method');
		return false;
	}
	if ( document.getElementById('workbenchPDB1').value =='' ) {
		alert('Please select PDB1');
		return false;
	}
	if ( document.getElementById('workbenchChain1').value =='' ) {
		alert('Please select Chain1');
		return false;
	}
	if ( document.getElementById('workbenchPDB2').value =='' ) {
		alert('Please select PDB2');
		return false;
	}
	if ( document.getElementById('workbenchChain2').value =='' ) {
		alert('Please select Chain2');
		return false;
	}
	return true;
}
function wb_redirectPage(){
	var wb_action = document.getElementById('workbenchAction').value;
	var wb_pdb1 = document.getElementById('workbenchPDB1').value;
	var wb_chain1 = document.getElementById('workbenchChain1').value;
	var wb_pdb2 = document.getElementById('workbenchPDB2').value;
	var wb_chain2 = document.getElementById('workbenchChain2').value;
	var wb_url = "http://www.rcsb.org/pdb/workbench/workbench.do?action="+wb_action+"&mol="+wb_pdb1+"."+wb_chain1+"&mol="+wb_pdb2+"."+wb_chain2;
	window.open(wb_url,'');
}
document.write("<table style='" + fontStyle + "padding:0;margin:0;width:" + wb_width + ";'><tr><td>");
document.write("<div style='background:" + wb_headerColor + ";color:#ffffff;-webkit-border-top-left-radius:10px;-webkit-border-top-right-radius:10px;-moz-border-radius-topleft:10px;-moz-border-radius-topright:10px;padding:0;border:1px solid " + wb_headerColor + ";border-bottom:0px;width:100%;'>");
document.write("<div style='padding:10px;'><b>RCSB PDB Comparison Tool</b></div>");
document.write("</div>");
document.write("<div style='background:" + wb_bodyColor + ";color:#333333;padding:0;border:1px solid " + wb_headerColor + ";border-top:0px;border-bottom:0px;text-align:center;width:100%;'>");
document.write("<div style='padding:5px;background:transparent;'>");
document.write("Compare the following two proteins:<br /><br />");
document.write("<form name='workbenchSelectPDBs' action='' onsubmit='wb_Submit(); return false;'>");
document.write("<table align='center' style='border:0px;width:95%;'>");
document.write("<tr><td style='"+fontStyle+"'>PDB1: <input type='text' name='workbenchPDB1' id='workbenchPDB1' size='4' maxlength='4'/></td><td style='"+fontStyle+"'>Chain1: <input type='text' name='workbenchChain1' id='workbenchChain1' size='4' maxlength='1'/></td></tr>");
document.write("<tr><td style='"+fontStyle+"'>PDB2: <input type='text' name='workbenchPDB2' id='workbenchPDB2' size='4' maxlength='4'/></td><td style='"+fontStyle+"'>Chain2: <input type='text' name='workbenchChain2' id='workbenchChain2' size='4' maxlength='1'/></td></tr>");
document.write("</table>");
document.write("<select name='workbenchAction' id='workbenchAction'>");
document.write("<option >-- Select Method --</option>");
document.write("<optgroup label='Sequence Alignment'>");
document.write("<option value='pw_blast2seq'>blast2seq</option>");
document.write("<option value='pw_needlemanwunsch'>Needleman-Wunsch</option>");
document.write("<option value='pw_smithwaterman'>Smith-Waterman</option>");
document.write("<optgroup label='Structure Alignment'>");
document.write("<option value='pw_fatcat'>JFatCat (rigid, javaws)</option>");
document.write("<option value='pw_fatcat_flexible'>jFatCat (flexible, javaws)</option>");
document.write("<option value='pw_fatcat_flexible'>jFatCat (flexible, javaws)</option>");
document.write("<option value='pw_ce'>jCE (CE, javaws)</option>");
document.write("<option value='pw_fatcat_server'>server: FatCat</option>");
document.write("<option value='pw_mammoth'>server: Mammoth</option>");
document.write("<option value='pw_tmalign'>server: TM-Align</option>");
document.write("<option value='pw_topmatch'>server: TopMatch</option>");

document.write("</select><br />");
document.write("<input type='submit' value='Compare' />");
document.write("</form>");
document.write("</div>");
document.write("</div>");
document.write("<div style='background:" + wb_bodyColor + ";color:#333333;-webkit-border-bottom-left-radius:10px;-webkit-border-bottom-right-radius:10px;-moz-border-radius-bottomleft:10px;-moz-border-radius-bottomright:10px;padding:0;border:1px solid " + wb_headerColor + ";border-top:0px;height:10px;overflow:hidden;text-align:center;width:100%;'>");
//document.write("<a rel='license' href='http://creativecommons.org/licenses/by-nc-sa/3.0/us/'><img alt='Creative Commons License' style='border-width:0' src='http://i.creativecommons.org/l/by-nc-sa/3.0/us/80x15.png' /></a>");
document.write("</div>");
document.write("</tr></td></table>");
document.close();


