String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
// ---------------------------------------------------------- //
/* index.jsp */
function changeDatabase(organism)
{
	if(organism == 'human')
	{
		document.snpflanking_form.build.options[0] = new Option('dbSNP b126_36_1' ,'b126_36_1');
		document.snpflanking_form.build.length = 1;
	}
	else if(organism == 'mouse')
	{
		document.snpflanking_form.build.options[0] = new Option('dbSNP b126_36_1' ,'b126_36_1');
		document.snpflanking_form.build.length = 1;
	}
	else if(organism == 'rat')
	{
		document.snpflanking_form.build.options[0] = new Option('dbSNP b125_3_1' ,'b125_3_1');
		document.snpflanking_form.build.length = 1;
	}
}

// check rs# input
function chkSNP_id()
{
	// judge empty
	if((rsId=document.snpflanking_form.rsId.value) == "")
		window.alert("No rs# be input.");
	else	// judge numerical
	{
		rsId = rsId.trim();
		// rs# filter
		if(rsId.length > 2)
		{
			if(rsId.substring(0,2) == "rs")
				rsId = rsId.substring(2);
		}
		if(isNaN(rsId))
			window.alert("rs# input error.");
		else		
			document.snpflanking_form.submit();
	}
}

// input rs#
function setSNPID(rsId, organism)
{
	if(organism == "human")
		document.snpflanking_form.organism[0].click();
	else if(organism == "mouse")
		document.snpflanking_form.organism[1].click();
	else if(organism == "rat")
		document.snpflanking_form.organism[2].click();
	document.snpflanking_form.rsId.value = rsId;
}

// clear sequence
function clearSeq()
{
	document.seq_form.sequence.value = "";
}

// constraint all
function constraintAll(type)
{
	if(type == "seq")
	{
		document.seq_form.primerLen[0].checked = true;
		document.seq_form.prinerLen_diff[0].checked = true;
		document.seq_form.tm[0].checked = true;
		document.seq_form.tm_diff[0].checked = true;
		document.seq_form.na[0].checked = true;
		document.seq_form.gc_proportion[0].checked = true;
		document.seq_form.pcrLen[0].checked = true;
	}
	else if(type == "file")
	{
		document.file_form.primerLen[0].checked = true;
		document.file_form.prinerLen_diff[0].checked = true;
		document.file_form.tm[0].checked = true;
		document.file_form.tm_diff[0].checked = true;
		document.file_form.na[0].checked = true;
		document.file_form.gc_proportion[0].checked = true;
		document.file_form.pcrLen[0].checked = true;
	}
}

// pcr_ratio select
function pcr_ratio_sel(type)
{
	if(type == "seq")
		document.seq_form.pcr_ratio[0].checked = true;
	else if(type == "file")
		document.file_form.pcr_ratio[0].checked = true;
}

// mutagenicLen select
function mutagenicLen_sel(type)
{
	if(type == "seq")
		document.seq_form.mutagenicLen[0].checked = true;
	else if(type == "file")
		document.file_form.pcr_ratio[0].checked = true;
}

// default all
function defaultAll(type)
{
	if(type == "seq")
	{
		document.seq_form.primerLen[1].checked = true;
		document.seq_form.prinerLen_diff[1].checked = true;
		document.seq_form.tm[1].checked = true;
		document.seq_form.tm_diff[1].checked = true;
		document.seq_form.na[1].checked = true;
		document.seq_form.gc_proportion[1].checked = true;
		document.seq_form.pcrLen[1].checked = true;
	}
	else if(type == "file")
	{
		document.file_form.primerLen[1].checked = true;
		document.file_form.prinerLen_diff[1].checked = true;
		document.file_form.tm[1].checked = true;
		document.file_form.tm_diff[1].checked = true;
		document.file_form.na[1].checked = true;
		document.file_form.gc_proportion[1].checked = true;
		document.file_form.pcrLen[1].checked = true;
	}
}

// pcr_ratio default
function pcr_ratio_default(type)
{
	if(type == "seq")
		document.seq_form.pcr_ratio[1].checked = true;
	else if(type == "file")
		document.file_form.pcr_ratio[1].checked = true;
}

// mutagenicLen default
function mutagenicLen_default(type)
{
	if(type == "seq")
		document.seq_form.mutagenicLen[1].checked = true;
	else if(type == "file")
		document.file_form.mutagenicLen[1].checked = true;
}

// ckeck all box
function chkBoxAll(type)
{
	if(type == "seq")
	{
		document.seq_form.gc_clamp.checked = true;
		document.seq_form.dimer.checked = true;
		document.seq_form.hairpin.checked = true;
		document.seq_form.blast.checked = true;
	}
	else if(type == "file")
	{
		document.file_form.gc_clamp.checked = true;
		document.file_form.dimer.checked = true;
		document.file_form.hairpin.checked = true;
		document.file_form.blast.checked = true;
	}
}

// cancel all box
function cnlBoxAll(type)
{
	if(type == "seq")
	{
		document.seq_form.gc_clamp.checked = false;
		document.seq_form.dimer.checked = false;
		document.seq_form.hairpin.checked = false;
		document.seq_form.blast.checked = false;
	}
	else if(type == "file")
	{
		document.file_form.gc_clamp.checked = false;
		document.file_form.dimer.checked = false;
		document.file_form.hairpin.checked = false;
		document.file_form.blast.checked = false;
	}
}

// mail clear
function clearMail(type)
{
	if(type == "seq")
		document.seq_form.email.value = "";
	else if(type == "file")
		document.file_form.email.value = "";
}


// ---------------------------------------------------------- //
/* notFindSeq.jsp */
// goback. (notFindSeq.jsp)
function goback()
{
	history.go(-1);
}