/////////////////////////////////////////////////////////////////
// page-builder.js
//
// Template routines for building the CONTRA pages
/////////////////////////////////////////////////////////////////

var CONTRA = 0;
var CONTRALIGN = 1;
var CONTRAFOLD = 2;
var CONTRAST = 3;
var NUM_PROGRAMS = 4;

// toolbar options

var toolbar_options = ["Home", "CONTRAlign", "CONTRAfold", "CONTRAST"];
var toolbar_links = [
	"./",
	"contralign/",
	"contrafold/",
	"contrast/"
];

// menu options

var menu_options = new Array(
	[],
	["Description", "Server", "Download", "FAQ", "Links"],
	["Description", "Server", "Download", "RAF", "FAQ", "Links"],
	["Description", "Server", "Download", "FAQ", "Links"]
);

var menu_links = new Array(
	[],
	["index.html", "server.html", "download.html", "faq.html", "links.html"],
	["index.html", "server.html", "download.html", "raf.html", "faq.html", "links.html"],
	["index.html", "server.html", "download.html", "faq.html", "links.html"]
);


/////////////////////////////////////////////////////////////////
// ShowBanner()
//
// Print banner for each program.
/////////////////////////////////////////////////////////////////

function ShowBanner (program_type){
	document.write ("<div id=\"banner\">\n");

	if (program_type == CONTRA){
		document.write ("	<span id=\"contra_logo\"></span>\n");
		document.write ("	<a href=\"./\"><h1>The <span class=\"highlight\">CONTRA</span> Project</h1></a><br />\n");
		document.write ("	<h2><span class=\"highlight\">CON</span>ditional <span class=\"highlight\">TRA</span>ining for Biosequence Analysis</h2>\n");
	} else if (program_type == CONTRALIGN){
		document.write ("	<span id=\"contralign_logo\"></span>\n");
		document.write ("	<a href=\"./\"><h1><span class=\"highlight\">CONTRA</span>lign</h1></a><br />\n");
		document.write ("	<h2><span class=\"highlight\">CON</span>ditional <span class=\"highlight\">TRA</span>ining for Protein Sequence Alignment</h2>\n");

	} else if (program_type == CONTRAFOLD){
		document.write ("	<span id=\"contrafold_logo\"></span>\n");
		document.write ("	<a href=\"./\"><h1><span class=\"highlight\">CONTRA</span>fold</h1></a><br />\n");
		document.write ("	<h2><span class=\"highlight\">CON</span>ditional <span class=\"highlight\">TRA</span>ining for RNA Secondary Structure Prediction</h2>\n");
	} else if (program_type == CONTRAST){
		document.write ("	<span id=\"contrast_logo\"></span>\n");
		document.write ("	<a href=\"./\"><h1><span class=\"highlight\">CONTRA</span>ST</h1></a><br />\n");
		document.write ("	<h2><span class=\"highlight\">CON</span>ditionally <span class=\"highlight\">TRA</span>ined Search for Transcripts</h2>\n");
	}
	document.write ("</div>\n\n");
}

/////////////////////////////////////////////////////////////////
// ShowToolbar()
//
// Print toolbar showing the selected program.
/////////////////////////////////////////////////////////////////

function ShowToolbar (program_type){

	document.write ("<div id=\"toolbar\">");
	document.write ("	<center>\n");

	for (var i = 0; i < NUM_PROGRAMS; i++){
		document.write ("		<a");
		if (program_type == i) document.write (" class=\"selected\"");
		document.write (" href=\"" + (program_type != CONTRA ? "../" : "") + toolbar_links[i] + "\">" + toolbar_options[i] + "</a>\n");
	}

	document.write ("	</center>\n");
	document.write ("</div>\n");
}

/////////////////////////////////////////////////////////////////
// ShowMenu()
//
// Print menu for the selected program.
/////////////////////////////////////////////////////////////////

function ShowMenu (program_type, menu_option){
	document.write ("<center>\n");
	document.write ("	<span id=\"menu\">\n");
	document.write ("		[\n");
	
	for (var i = 0; i < menu_options[program_type].length; i++){
		document.write ("		<a");
		if (menu_options[program_type][i] == menu_option) document.write (" class=\"selected\"");
		document.write (" href=\"" + menu_links[program_type][i] + "\">" + menu_options[program_type][i] + "</a>");
		if (i < menu_options[program_type].length - 1) document.write (" |");
	}
	document.write ("		]\n");
	document.write ("	</span>\n");
	document.write ("</center>\n");
}

/////////////////////////////////////////////////////////////////
// ShowHeader()
//
// Print header for each program.
/////////////////////////////////////////////////////////////////

function ShowHeader (program_type, menu_option){
	ShowBanner (program_type);
	ShowToolbar (program_type);
	if (program_type != CONTRA && program_type != CONTRAST) ShowMenu (program_type, menu_option);	
}

/////////////////////////////////////////////////////////////////
// ShowFooter()
//
// Print page footer.
/////////////////////////////////////////////////////////////////

function ShowFooter (){
	document.write ("	<hr>\n");
	document.write ("	<div id=\"footer\">\n");
	document.write ("               Site design by Chuong Do.  Artwork by Marina Sirota.<br /><br />");
	document.write ("		Comments?  Questions?  Send us <a href=\"mailto:chuong");
	document.write ("do@cs.stan");
	document.write ("ford.edu\">feedback</a>.\n");
	document.write ("	</div>\n");
}
