var blueText = new Array();
var whiteText = new Array();
var stuff = new Array('home', 'summary', 'personnel', 'database', 'account', 'loginout');

var pathToRoot = "./";
function setPathToRoot (path)
{
	pathToRoot = path;
}

//preload images
function preload ()
{
	var base = pathToRoot + "img/";
	if (document.images)
	{
		for (i=0;i<stuff.length;i++)
		{
			blueText[i] = new Image;
			blueText[i].src = base + stuff[i] + ".jpg"
			whiteText[i] = new Image;
			whiteText[i].src = base + stuff[i] + "2.jpg";
		}
	}
}


// The functions: first mouseover, then mouseout
function mouseOver(no)
{
	if (document.images)
	{
		document.images[stuff[no]].src = whiteText[no].src
	}
}

function mouseOut(no)
{
	if (document.images)
	{
		document.images[stuff[no]].src = blueText[no].src
	}
}


function writeBanner(category)
{
	var htmlContent = "";
	
	htmlContent += "<IMG SRC='" + pathToRoot + "img/banner.gif', BORDER=0, WIDTH=820, ALT='ProteomicsQuest Project'><BR>";
//	htmlContent += "<IMG SRC='" + pathToRoot + "img/empty.jpg'>";
	if (category == 0)
	{
		htmlContent += "<A HREF='http://vision.biotech.ufl.edu'><IMG SRC='" + pathToRoot + "img/home2.jpg' BORDER=0, ALT='Biotechnology Vision Server Home', NAME='home'></A>";
	} else {
		htmlContent += "<A HREF='http://vision.biotech.ufl.edu'><IMG SRC='" + pathToRoot + "img/home.jpg' BORDER=0, ALT='Biotechnology Vision Server Home', NAME='home',  onMouseOver='mouseOver(0)', onMouseOut='mouseOut(0)'></A>";
	}
	if (category == 1)
	{
		htmlContent += "<A HREF='" + pathToRoot + "./summary.html'><IMG SRC='" + pathToRoot + "img/summary2.jpg' BORDER=0, ALT='Project Summary', NAME='summary'></A>";
	} else {
		htmlContent += "<A HREF='" + pathToRoot + "./summary.html'><IMG SRC='" + pathToRoot + "img/summary.jpg' BORDER=0, ALT='Project Summary', NAME='summary',  onMouseOver='mouseOver(1)', onMouseOut='mouseOut(1)'></A>";
	}
	if (category == 3)
	{
		htmlContent += "<A HREF='" + pathToRoot + "jsp/project/projects.jsp'><IMG SRC='" + pathToRoot + "img/database2.jpg' BORDER=0, ALT='ProteomicsQuest Database', NAME='database'></A>";
	} else {
		htmlContent += "<A HREF='" + pathToRoot + "jsp/project/projects.jsp'><IMG SRC='" + pathToRoot + "img/database.jpg' BORDER=0, ALT='ProteomicsQuest Database', NAME='database',  onMouseOver='mouseOver(3)', onMouseOut='mouseOut(3)'></A>";
	}
	if (category == 4)
	{
		htmlContent += "<A HREF='" + pathToRoot + "jsp/account/addProject.jsp?msg=start'><IMG SRC='" + pathToRoot + "img/account2.jpg' BORDER=0, ALT='Manage Account', NAME='account'></A>";
	} else {
		htmlContent += "<A HREF='" + pathToRoot + "jsp/account/addProject.jsp?msg=start'><IMG SRC='" + pathToRoot + "img/account.jpg' BORDER=0, ALT='Manage Account', NAME='account',  onMouseOver='mouseOver(4)', onMouseOut='mouseOut(4)'></A>";
	}
	if (category == 2)
	{
		htmlContent += "<A HREF='" + pathToRoot + "./personnel.html'><IMG SRC='" + pathToRoot + "img/personnel2.jpg' BORDER=0, ALT='Personnel', NAME='personnel'></A>";
	} else {
		htmlContent += "<A HREF='" + pathToRoot + "./personnel.html'><IMG SRC='" + pathToRoot + "img/personnel.jpg' BORDER=0, ALT='Personnel', NAME='personnel',  onMouseOver='mouseOver(2)', onMouseOut='mouseOut(2)'></A>";
	}
	if (category == 5)
	{
		htmlContent += "<A HREF='" + pathToRoot + "jsp/login.jsp'><IMG SRC='" + pathToRoot + "img/loginout2.jpg' BORDER=0, ALT='Log In / Log Out', NAME='loginout'></A>";
	} else {
		htmlContent += "<A HREF='" + pathToRoot + "jsp/login.jsp'><IMG SRC='" + pathToRoot + "img/loginout.jpg' BORDER=0, ALT='Log In / Log Out', NAME='loginout',  onMouseOver='mouseOver(5)', onMouseOut='mouseOut(5)'></A>";
	}

	htmlContent += "<BR CLEAR='all'>";
	
	document.write(htmlContent);
}

function writeLeftMenu(category) {
	var htmlContent = "";
	htmlContent += "<TABLE>";
	htmlContent += "<TR>";
	htmlContent += "<TD VALIGN='top' ALIGN='left' WIDTH='150' NOWRAP>";
	htmlContent += "<BR><BR>";
	if (category == -1)
	{
	} else if (category == 1)
	{
		htmlContent += "<A HREF='" + pathToRoot + "summary.html'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>System Summary</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "publication.html'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Publications</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "funding.html'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Funding Agencies</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "manual.html'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>User Manual</I></B></FONT></A><BR><BR>";
	} else if (category == 3)
	{
		htmlContent += "<A HREF='" + pathToRoot + "jsp/project/projects.jsp'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Annotation Projects</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/project/description.jsp'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Project Description</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/project/overview.jsp'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Global Overview</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/project/contigs.jsp'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Contig Browser</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/project/superContigs.jsp'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Super Contigs</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/project/functions.jsp'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Function Categories</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/project/search.jsp'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Search Engine</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/project/trackUpdates.jsp?msg=start'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Track Updates</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/project/blast.jsp?msg=start'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>BLAST Search</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/project/download.jsp'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Download Center</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/project/supplementary.jsp'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Supplementary Data</I></B></FONT></A><BR><BR>";
		htmlContent += "<BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/project/folder.jsp'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Your Folder</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/project/updateUserProfile.jsp?msg=start'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Update Your Profile</I></B></FONT></A><BR><BR>";
	} else if (category == 4)
	{
		htmlContent += "<A HREF='" + pathToRoot + "jsp/account/addUser.jsp?msg=start'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Add New User</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/account/addProject.jsp?msg=start'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Add New Project</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/account/deleteProject.jsp?msg=start'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Delete Project</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/account/loadContig.jsp?msg=start'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Load Contigs</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/account/loadElement.jsp?msg=start'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Load Gene Elements</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/account/loadFunctionAnnotation.jsp?msg=start'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Load Funct. Anno.</I></B></FONT></A><BR><BR>";
		htmlContent += "<A HREF='" + pathToRoot + "jsp/account/loadEvidence.jsp?msg=start'><FONT FACE='Arial' COLOR='12976A' SIZE=2><B><I>Load Evidences</I></B></FONT></A><BR><BR>";
	}
	htmlContent += "</TD>";
	htmlContent += "<TD VALIGN='top' ALIGN='left' WIDTH=800>";
	htmlContent += "<FONT FACE='Arial' SIZE='2'>";
	htmlContent += "<BR CLEAR='all'>";

	document.write(htmlContent);
}

function writeFooter()
{
	var htmlContent = "";
	htmlContent += "</FONT>";
	htmlContent += "</TD>";
	htmlContent += "</TR>";
	htmlContent += "</TABLE>";

	document.write(htmlContent);
}

function changePageSize (thisForm) {
	document.forms[0].submit();
	return true;
}
			
function confirmDelete (msg) {
	var agree = confirm("Delete this " + msg + " and all its related results?");
	if (agree)
	{
		return true;
	} else {
		return false;
	}
}
				
function activateChangePassword () {
	if (document.updateUserProfile.changePassword.checked)
	{
		document.updateUserProfile.password1.disabled = false;
		document.updateUserProfile.password2.disabled = false;
	} else {
		document.updateUserProfile.password1.disabled = true;
		document.updateUserProfile.password2.disabled = true;
	}
}

function changeScreenSize(w,h)
{
	window.resizeTo( w,h )
}

function writeMonthSelections(name)
{
	document.write('<SELECT NAME=' + name + '>');
	document.write('<OPTION VALUE="0" SELECTED>Month');
	document.write('<OPTION VALUE="01">Jan');
	document.write('<OPTION VALUE="02">Feb');
	document.write('<OPTION VALUE="03">Mar');
	document.write('<OPTION VALUE="04">Apr');
	document.write('<OPTION VALUE="05">May');
	document.write('<OPTION VALUE="06">Jun');
	document.write('<OPTION VALUE="07">Jul');
	document.write('<OPTION VALUE="08">Aug');
	document.write('<OPTION VALUE="09">Sep');
	document.write('<OPTION VALUE="10">Oct');
	document.write('<OPTION VALUE="11">Nov');
	document.write('<OPTION VALUE="12">Dec');
	document.write('</SELECT>');
}

function writeDaySelections(name)
{
	document.write('<SELECT NAME=' + name + '>');
	document.write('<OPTION VALUE="0" SELECTED>Day');
	document.write('<OPTION VALUE="01">01');
	document.write('<OPTION VALUE="02">02');
	document.write('<OPTION VALUE="03">03');
	document.write('<OPTION VALUE="04">04');
	document.write('<OPTION VALUE="05">05');
	document.write('<OPTION VALUE="06">06');
	document.write('<OPTION VALUE="07">07');
	document.write('<OPTION VALUE="08">08');
	document.write('<OPTION VALUE="09">09');
	document.write('<OPTION VALUE="10">10');
	document.write('<OPTION VALUE="11">11');
	document.write('<OPTION VALUE="12">12');
	document.write('<OPTION VALUE="13">13');
	document.write('<OPTION VALUE="14">14');
	document.write('<OPTION VALUE="15">15');
	document.write('<OPTION VALUE="16">16');
	document.write('<OPTION VALUE="17">17');
	document.write('<OPTION VALUE="18">18');
	document.write('<OPTION VALUE="19">19');
	document.write('<OPTION VALUE="20">20');
	document.write('<OPTION VALUE="21">21');
	document.write('<OPTION VALUE="22">22');
	document.write('<OPTION VALUE="23">23');
	document.write('<OPTION VALUE="24">24');
	document.write('<OPTION VALUE="25">25');
	document.write('<OPTION VALUE="26">26');
	document.write('<OPTION VALUE="27">27');
	document.write('<OPTION VALUE="28">28');
	document.write('<OPTION VALUE="29">29');
	document.write('<OPTION VALUE="30">30');
	document.write('<OPTION VALUE="31">31');
	document.write('</SELECT>');
}

function writeYearSelections(name)
{
	document.write('<SELECT NAME=' + name + '>');
	document.write('<OPTION VALUE="0" SELECTED>Year');
	document.write('<OPTION VALUE="2004">2004');
	document.write('<OPTION VALUE="2005">2005');
	document.write('<OPTION VALUE="2006">2006');
	document.write('</SELECT>');
}

function selectiveDisableAnnotationResource(selectedResource) {
	if (selectedResource == 'FGENESB')
	{
		document.loadAnnotation.externalName.value = 'FGENESB';
		document.loadAnnotation.externalName.disabled = true;
		document.loadAnnotation.genomeSeqFile.disabled = false;
		document.loadAnnotation.contigMapFile.disabled = false;
	} else if (selectedResource == "external"){
		document.loadAnnotation.externalName.value = '';
		document.loadAnnotation.externalName.disabled = false;
		document.loadAnnotation.genomeSeqFile.disabled = true;
		document.loadAnnotation.contigMapFile.disabled = true;
	}
}
		
function selectiveDisableSelectProject (selectedUserGroup) {
	if (selectedUserGroup == '1')
	{
		document.userInfo.projectID.value = '-100';
		document.userInfo.privilege.value = '';
		document.userInfo.projectID.disabled = true;
		document.userInfo.privilege.disabled = true;
	} else if (selectedUserGroup == '2') {
		document.userInfo.privilege.value = 'write';
		document.userInfo.projectID.disabled = false;
		document.userInfo.privilege.disabled = true;
	} else {
		document.userInfo.privilege.value = '';
		document.userInfo.projectID.disabled = false;
		document.userInfo.privilege.disabled = false;
	}
}
