function checkall()
{
	for(i=0; i< obj.elements.length; i++)
	{
		if(obj.elements[i].type == "checkbox")
		{
			obj.elements[i].checked=true;
		}
	}
}
function UnCheckall()
{
	for(i=0; i< obj.elements.length; i++)
	{
		if(obj.elements[i].type == "checkbox")
		{
			obj.elements[i].checked=false;
		}
	}
}
function Blast(par)
{
    obj.method = "post"
	obj.action = "http://www.ncbi.nlm.nih.gov/blast/Blast.cgi?CMD=Web&LAYOUT=OneWindow&AUTO_FORMAT=Semiauto&ALIGNMENTS=100&ALIGNMENT_VIEW=Pairwise&CLIENT=web&DATABASE=nr&DESCRIPTIONS=100&QUERY="+par+"&EXPECT=1000&FORMAT_OBJECT=Alignment&FORMAT_TYPE=HTML&HITLIST_SIZE=100&NCBI_GI=on&PAGE=Nucleotides&PROGRAM=blastn&SERVICE=plain&SET_DEFAULTS.x=29&SET_DEFAULTS.y=6&SHOW_OVERVIEW=on&WORD_SIZE=7&END_OF_HTTPGET=Yes&SHOW_LINKOUT=yes";
	//obj.action = "http://www.ncbi.nlm.nih.gov/blast/Blast.cgi?PROGRAM=blastn&CLIENT=web&SERVICE=plain&PAGE=Nucleotides&CMD=Put&QUERY="+par+"&DATABASE=nr";
	obj.target = "_blank";
	obj.submit();
	return true;
}
function Calculate(form) {
	thePept = new Pept(obj.txtDnaSequence.value);
	obj.txtDnaSequence.value = thePept.Sequence;
	obj.txtDnaEnd.value = thePept.Sequence.length;
	obj.txtDnaStart.value = 1;


}
function Pept(theString)
{
	theString = theString.toLowerCase()
	this.Sequence = RemoveNonRes(theString)


}

function RemoveNonRes(theString) {
	var returnString = "";
	for ( var i = 0; i < theString.length; i++) {
		if (IsRes(theString.charAt(i))) {
			returnString += theString.charAt(i);
		}
	}
	return returnString
}

function CountChar(theString,theChar) {
	var returnValue = 0;
	for ( var i = 0; i < theString.length; i++) {
		if (theString.charAt(i) == theChar) {
			returnValue ++;
		}
	}
	return returnValue
}

function DoCheck(PeptBox) {
	PeptBox.value = CheckRes(PeptBox.value)
}

function IsRes(theRes) {
 if ((theRes == "a") ||
	(theRes == "b") ||
	(theRes == "c") ||
	(theRes == "d") ||
	(theRes == "e") ||
	(theRes == "f") ||
	(theRes == "g") ||
	(theRes == "h") ||
	(theRes == "i") ||
	(theRes == "k") ||
	(theRes == "l") ||
	(theRes == "m") ||
	(theRes == "n") ||
	(theRes == "p") ||
	(theRes == "q") ||
	(theRes == "r") ||
	(theRes == "s") ||
	(theRes == "t") ||
	(theRes == "v") ||
	(theRes == "w") ||
	(theRes == "y") ||
	(theRes == "z") ) {
		return 1
	}
	return 0
}
function View_Result()
{
	if(obj.txtDnaSequence.value == "" )
	{	//most of these checks are self explanitory
		alert("Please enter a Dna Sequence!!");
		obj.txtDnaSequence.focus();
		return false;
	}
	if(obj.txtDnaStart.value == "" )
	{	//most of these checks are self explanitory
		alert("Please enter a Start Value for Dna Sequence!!");
		obj.txtDnaStart.focus();
		return false;
	}
	if(obj.txtDnaEnd.value == "" )
	{	//most of these checks are self explanitory
		alert("Please enter a End Value for Dna Sequence!!");
		obj.txtDnaEnd.focus();
		return false;
	}
	if(obj.txtStart.value == "" )
	{	//most of these checks are self explanitory
		alert("Please enter a Nucleotide Target Value!!");
		obj.txtStart.focus();
		return false;
	}
	if(obj.txtMotif.value == "" )
	{	//most of these checks are self explanitory
		alert("Please enter a siRNA Number!!");
		obj.txtMotif.focus();
		return false;
	}
	if(obj.txtStartNt.value == "" )
	{	//most of these checks are self explanitory
		alert("Please enter a First nucleotide target for siRNA!!");
		obj.txtStartNt.focus();
		return false;
	}
	if(obj.txtGCPercentStart.value == "" )
	{	//most of these checks are self explanitory
		alert("Please enter a G+C% Start Value!!");
		obj.txtGCPercentStart.focus();
		return false;
	}
	if(obj.txtGCPercentEnd.value == "" )
	{	//most of these checks are self explanitory
		alert("Please enter a G+C% End Value!!");
		obj.txtGCPercentEnd.focus();
		return false;
	}
	if(obj.txtARepeats.value == "" )
	{	//most of these checks are self explanitory
		alert("Please enter 'A' Repeats Value!!");
		obj.txtARepeats.focus();
		return false;
	}
	if(obj.txtTRepeats.value == "" )
	{	//most of these checks are self explanitory
		alert("Please enter 'T' Repeats Value!!");
		obj.txtTRepeats.focus();
		return false;
	}
	if(obj.txtCRepeats.value == "" )
	{	//most of these checks are self explanitory
		alert("Please enter 'C' Repeats Value!!");
		obj.txtCRepeats.focus();
		return false;
	}
	if(obj.txtGRepeats.value == "" )
	{	//most of these checks are self explanitory
		alert("Please enter 'G' Repeats Value!!");
		obj.txtGRepeats.focus();
		return false;
	}
	obj.action = "sirna_tool_details.php?opt=view_result";
	obj.target = "_parent";
	obj.submit();
}
function createNewWindow()
{
	window.open("about:blank", "MyWindow","height=405,width=625,location=0,resizable=1,toolbar=0,statusbar=0,scrollbars=1,menubar=1, top=230,left=500,screenX=50,screenY=50");
}
function Printable()
{
	createNewWindow();
	obj.target = "MyWindow";
	obj.action = "sirna_tool_printable.php";
	obj.submit();
}

function View_Sirna()
{
	var num = 0;
	for(i=0;i<obj.elements.length;i++)
	{
		if(obj.elements[i].type == "checkbox")
		{
			if(obj.elements[i].checked == true)
			{
				num++;
			}
		}
	}
	if(num == 0)
	{
		alert("Please select a Sequence.");
		return;
	}
	createNewWindow();
	obj.target = "MyWindow";
	obj.action = "sirna_result.php";
	obj.submit();
}
function View_Blast()
{
	obj.method = "post"
	obj.action = "http://www.ncbi.nlm.nih.gov/blast/Blast.cgi";
	obj.target = "_blank";
	obj.submit();
}
function View_GenBank_ret()
{
    if (event.keyCode == 13)
	{
		if(obj.txtGenBankNos.value == "" )
		{	//most of these checks are self explanitory
			alert("Please enter a GenBank Number for mRNA!!");
			obj.txtGenBankNos.focus();
			return false;
		}
		else
		{
			self.location = "sirna_tool.php?opt=getcds&genBankNo="+obj.txtGenBankNos.value;
		}
	}
}
function Show_GenBank_ret()
{
    if (event.keyCode == 13)
	{
		if(obj.txtGenBankNosP.value == "" )
		{	//most of these checks are self explanitory
			alert("Please enter a GenBank Number for Protein!!");
			obj.txtGenBankNosP.focus();
			return false;
		}
		else
		{
			self.location = "sirna_tool.php?opt=getpts&genBankNoP="+obj.txtGenBankNosP.value;
		}
	}
}
function View_GenBank()
{
	if(obj.txtGenBankNos.value == "" )
	{	//most of these checks are self explanitory
		alert("Please enter a GenBank Number for mRNA!!");
		obj.txtGenBankNos.focus();
		return false;
	}
	self.location = "sirna_tool.php?opt=getcds&genBankNo="+obj.txtGenBankNos.value;
}
function Show_GenBank()
{
	if(obj.txtGenBankNosP.value == "" )
	{	//most of these checks are self explanitory
		alert("Please enter a GenBank Number for Protien!!");
		obj.txtGenBankNosP.focus();
		return false;
	}
	self.location = "sirna_tool.php?opt=getpts&genBankNoP="+obj.txtGenBankNosP.value;
}

