	var isNS4 = (navigator.appName=="Netscape")?1:0;
	var maxx = 100; var maxy = 2; var count = 0;
	var graph = new Array(maxx)
	allok = new Boolean(true)
	for (x = 0; x <= maxx; x++) {graph [x] = new Array(maxy)}

	function sequencecheck() {
		var sequence = document.submit_form.seq.value;
		var secseq = document.submit_form.SSInfo.value;


		if(sequence.length>100)
		{
			alert('Please submit the sequence of length within 100 amino acids');
			return false;
		}
		if(sequence.length==0)
		{	
			alert('Please submit the sequence');
			return false;
		}
		if(secseq.length==0)
		{	
			alert('Please submit the Secondary Structure Data');
			return false;
		}
		if(count==1){
                        alert('Please submit atleast two Secondary Structure Data');
                        document.submit_form.startRange.focus();
                        return false;
		}
		if(document.submit_form.email.value.length==0)
		{
			alert('You have not mentioned your E-Mail Address.\n Please note your Job ID for retrival of results');
		}
	}
	function sequencechecknew() {
		var sequence = document.submit_form.seq.value;
		var secseq = document.submit_form.SSInfo.value;
		var email=document.submit_form.email.value;
			
		//if(sequence.length>1000)
		if(sequence.length>100)
		{
			//alert('Please submit the sequence of length within 1000 amino acids');
			alert('Redirecting to the Bhageerath-H as sequence length exceed 100');
			//return false;
		}
			
		if(sequence.length==0)
		{	
			alert('Please submit the sequence');
			return false;
		}
		if(email.length > 0) 
		{
		if(email.length==0 || (email.indexOf("@")==-1 ||  email.indexOf(".")==-1))
		{
				alert('Please enter a valid email address. ');
				 return false;
		}
		}
		var charge2 = document.submit_form.email.value;
		if(charge2 == null || charge2.length ==0)
		{
			 alert('Please enter the Email Id!!!');
				 return false;
		}
			 								 	 
		 if (submit_form.METHOD[1].checked)
		 {	
			if(secseq.length==0)
			{	
				alert('Please submit the Secondary Structure Data');
				return false;
			}
		
		 
			// alert('sequence');
		 }
		 
	/*	if(secseq.length==0)
		{	
			alert('Please submit the Secondary Structure Data');
			return false;
		}*/
		if(count==1){
                        alert('Please submit atleast two Secondary Structure Data');
                        document.submit_form.startRange.focus();
                        return false;
		}
		if(document.submit_form.email.value.length==0)
		{
			alert('You have not mentioned your E-Mail Address.\n Please note your Job ID for retrival of results');
		}
	}
	function check(){

		for(j=0;j<count;j++)
		{
			if(graph[j][1]>parseInt(document.submit_form.seq.value.length))
			{
				alert('Please check the length of Sequence and Secondary Structure Data');
				return false;
			}
		}
	}
	function changeSecondaryInfo(Ssecvalue){
		document.submit_form.Ssec[0].value=Ssecvalue;
	}
	
	function setinfo(value){
		document.submit_form.seq.value+=value;
	}
	
	function Clr(){
		document.submit_form.SSInfo.value="";
		document.submit_form.startRange.value="";
		document.submit_form.endRange.value="";
		count=0;

                graph=new Array(maxx);
                for (x = 0; x <= maxx; x++) {graph [x] = new Array(maxy)}
		document.submit_form.startRange.focus();

		return true;
	}

	function AddInfo(){
		var Initialvalue=document.submit_form.startRange.value;		
		var Finalvalue=document.submit_form.endRange.value;
		var Sec=document.submit_form.SSInfo.value;
		var len=document.submit_form.seq.value.length;
		var lastBlank;
		lastBlank=Sec.substring(Sec.lastIndexOf(" ")+1,Sec.length);

		

		if((Initialvalue.length>0)&&(Finalvalue>0))
		{
//		alert("length = "+len);
//		alert("count1 = "+count);
		if(count>3){
			alert('Current Hardware Limitations Donot Allow Structure Prediction\nof Protein With More Then Four Secondary Structures\n\nSorry For Inconvenience');
			allok=false;
			return false;
		 }
		 	
			if((parseInt(Finalvalue) > parseInt(Initialvalue))&&(parseInt(Finalvalue) > 0) && (parseInt(Initialvalue)> 0) && (parseInt(Finalvalue)<=len))
			{
				if(count==0)
				{
					document.submit_form.SSInfo.value=Sec + document.submit_form.HB.value + "  " + Initialvalue + "  " + Finalvalue + "\n";
					document.submit_form.startRange.value="";
					document.submit_form.endRange.value="";
					document.submit_form.startRange.focus();
					graph[count][0]=Initialvalue;
					graph[count][1]=Finalvalue;
					
					count++;
				}
				else
				{
					allok=true;
					for(i=0;i<count;i++)
					{
					//alert(graph[i][0]+" "+graph[i][1]);
						if(((parseInt(Initialvalue)>=graph[i][0])&&(parseInt(Initialvalue)<=graph[i][1]))||((parseInt(Finalvalue)>=graph[i][0])&&(parseInt(Finalvalue)<=graph[i][1]))||((parseInt(Initialvalue)<graph[i][0])&&(parseInt(Finalvalue)>graph[i][1])))
						{alert("Range is overlapping!");allok=false;}
					}
					if(allok)
					{
					//check val
					if(Sec.length > 0)
					{
					if(parseInt(lastBlank) < parseInt(Initialvalue))
					{
							if((Initialvalue.length > 0)&&(Finalvalue>0))
							{
								if((parseInt(Finalvalue) > parseInt(Initialvalue))&&(parseInt(Finalvalue) > 0) && (parseInt(Initialvalue)> 0))
								document.submit_form.SSInfo.value=Sec + document.submit_form.HB.value + "  " + Initialvalue + "  " + Finalvalue + "\n";
								else{
								alert('Range must be entered in the ascending order');
								return false;
								}
							}
					}
					else
					{
					alert('Range must be entered in the ascending order');
					return false;
		     		}
					}
					//end val
						document.submit_form.startRange.value="";
						document.submit_form.endRange.value="";
						graph[count][0]=Initialvalue;
						graph[count][1]=Finalvalue;
						count++;
					}
					
				}
			}
			else
			{   
				if(len==0){
				alert("Please enter the amino acid sequence");
				return false;
				}
				if(Initialvalue>Finalvalue)
				alert("Please check the values");
				if(len<Initialvalue||len<Finalvalue)
				alert("Range exceeds the amino acid length ("+len+")!");}
		}
		else
		{alert("Please check the values !!!");}
		
//		chek val in ascending order
//alert("count2 = "+count);
	}

	function changeChoice(optChoice){
		document.submit_form.CHOICEOPT[0].value=optChoice;
		document.submit_form.seq.value="";
	}


	function clearForm(){
		document.submit_form.reset();
		document.submit_form.seq.value="";
		document.submit_form.SSInfo.value="";
		count=0;
		
		graph=new Array(maxx);
		for (x = 0; x <= maxx; x++) {graph [x] = new Array(maxy)}
		document.submit_form.seq.focus();
		return true;
	}

	function popUp(URL){
		fname = document.getElementsByName("myFile")[0].value;
		if (fname != "")
			window.open(URL+"?first&uplMonitor="+encodeURIComponent(fname),"","width=400,height=150,resizable=yes,depend=yes")
	}
			function enableField()
			{
			document.submit_form.HB.disabled=false;
			document.submit_form.endRange.disabled=false;
			document.submit_form.startRange.disabled=false;
			document.submit_form.Add.disabled=false;
			document.submit_form.clc.disabled=false;
			//alert("hello");
			}
			function disableField()
			{
			//alert("hello");
			document.submit_form.HB.disabled=true;
			document.submit_form.endRange.disabled=true;
			document.submit_form.startRange.disabled=true;
			document.submit_form.Add.disabled=true;
			document.submit_form.clc.disabled=true;
			}               
	function AddInfo1(){
		var Initialvalue=document.submit_form.startRange.value;		
		var Finalvalue=document.submit_form.endRange.value;
		var Sec=document.submit_form.SSInfo.value;
		var len=document.submit_form.seq.value.length;
		var lastBlank;
		lastBlank=Sec.substring(Sec.lastIndexOf(" ")+1,Sec.length);

		

		if((Initialvalue.length>0)&&(Finalvalue>0))
		{
//		alert("length = "+len);
//		alert("count1 = "+count);
		if(count>5){
		            alert('Current hardware limitations do not allow structure prediction\nof protein with more than four secondary structures\n\nsorry for inconvenience');
						
			allok=false;
			return false;
		 }
		 	
			if((parseInt(Finalvalue) >= parseInt(Initialvalue))&&(parseInt(Finalvalue) > 0) && (parseInt(Initialvalue)> 0) && (parseInt(Finalvalue)<=len))
			{
				if(count==0)
				{
					document.submit_form.SSInfo.value=Sec + document.submit_form.HB.value + "  " + Initialvalue + "  " + Finalvalue + "\n";
					document.submit_form.startRange.value="";
					document.submit_form.endRange.value="";
					document.submit_form.startRange.focus();
					graph[count][0]=Initialvalue;
					graph[count][1]=Finalvalue;
					
					count++;
				}
				else
				{
					allok=true;
					for(i=0;i<count;i++)
					{
					//alert(graph[i][0]+" "+graph[i][1]);
						if(((parseInt(Initialvalue)>=graph[i][0])&&(parseInt(Initialvalue)<=graph[i][1]))||((parseInt(Finalvalue)>=graph[i][0])&&(parseInt(Finalvalue)<=graph[i][1]))||((parseInt(Initialvalue)<graph[i][0])&&(parseInt(Finalvalue)>graph[i][1])))
						{alert("Range is overlapping!");allok=false;}
					}
					if(allok)
					{
					//check val
					if(Sec.length > 0)
					{
					if(parseInt(lastBlank) < parseInt(Initialvalue))
					{
							if((Initialvalue.length > 0)&&(Finalvalue>0))
							{
								if((parseInt(Finalvalue) >= parseInt(Initialvalue))&&(parseInt(Finalvalue) > 0) && (parseInt(Initialvalue)> 0))
								document.submit_form.SSInfo.value=Sec + document.submit_form.HB.value + "  " + Initialvalue + "  " + Finalvalue + "\n";
								else{
								alert('Range must be entered in the ascending order');
								return false;
								}
							}
					}
					else
					{
					alert('Range must be entered in the ascending order');
					return false;
		     		}
					}
					//end val
						document.submit_form.startRange.value="";
						document.submit_form.endRange.value="";
						graph[count][0]=Initialvalue;
						graph[count][1]=Finalvalue;
						count++;
					}
					
				}
			}
			else
			{   
				if(len==0){
				alert("Please enter the amino acid sequence");
				return false;
				}
				if(Initialvalue>Finalvalue)
				alert("Please check the values");
				if(len<Initialvalue||len<Finalvalue)
				alert("Range exceeds the amino acid length ("+len+")!");}
		}
		else
		{alert("Please check the values !!!");}
		
//		chek val in ascending order
//alert("count2 = "+count);
	}

