	var conditionCnt = 0;
	var constraints = [];
	var objectFunctions = [];
	var objIdx = 0;
	 var fair;
	var solveResultFile ='';
	
	var isNewAnalysis = 0;
	
	var isShowResult = false;
	
	var selectedAnalysis = '';
	var beforeselectedAnalysis = '';
	var openConditionIdx = -1;
	
	var constraintSet = [];
	
	var conditionTotalPage = 1;
	var conditionCurrentPage = 1;
	var conditionCntForPage = 20;

	var resultTotalPage = 1;
	var resultCurrentPage = 1;
	var resultCntForPage = 20;
	
	var tempResultData = [];
	var tempResultData1 = [];
	
	function getAnalysisList()
   	{
    	removelAllArray(constraintSet);
    	var sendData = "action=getAnalysisList&pid="+projectIdx;
    	var getPost = "POST";                      
    	var urlFileAppl = "AnalysisServlet";
    	var trueFalse = isTrueOrFalse;                      

    	var xmlHttp = newXMLHttpRequest();            
   		xmlHttp.open(getPost, urlFileAppl, trueFalse);
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {                 
	            if (xmlHttp.status == 200) {                
	            	saveAnalysisList(xmlHttp);
	            } else {
	                exceptionControl(xmlHttp);          
                	alertMessage("CODE: 1010");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
    }
    
    function saveAnalysisList(xmlHttp)
    {
    	var xmlHttpData = xmlHttp.responseText;
    	var colSplit = xmlHttpData.split("<N>");
    	for(var i=0; i<colSplit.length-1; i++)
    	{
    		constraintSet.push(colSplit[i]);
    	}
    	showAnalysisList();
    }
    
    function showAnalysisList()
    {
      
    	var newTable = byId("analysisBody");
		deleteRowFromTable(newTable);
		
    	for(var i=0; i < constraintSet.length; i++)
    	{
    		var colSplit = constraintSet[i].split("<T>");
    		var div = document.createElement("DIV");
    		div.id = colSplit[0];
    		//div.innerHTML = "<a href='javascript:openCondition("+colSplit[0]+","+colSplit[3]+");'>"+colSplit[1]+"</a>("+colSplit[2]+")";; 
    		div.innerHTML = "<a href='javascript:openCondition("+colSplit[0]+","+colSplit[3]+");'>"+colSplit[1]+"</a>";; 
			
			var newRow = document.createElement("tr");
    		newRow.id = i;
			var newCol = document.createElement("td");			
			newCol.appendChild(div);
			
			newCol.style.borderBottom = "1px solid #ccc";
			newCol.style.borderLeft = "1px solid #ccc";
			newRow.appendChild(newCol);
			newTable.appendChild(newRow);	
		}
    }
    
    function deleteAnalysis(idx)
    {
    	for(var i=0; i < constraintSet.length; i++)
    	{
    		var colSplit = constraintSet[i].split("<T>");
    		if(idx == colSplit[0]){
	    		constraintSet.splice(idx,1);
	    		break;
	    	}
    	}
    	showAnalysisList();
    }
	
	function getPathwayListAll(comboName)
    {
    	var sendData = "cmd=pathwayListAll";
    	var getPost = "POST";                      
    	var urlFileAppl = "PathwayServlet";
    	var trueFalse = isTrueOrFalse;                      

    	var xmlHttp = newXMLHttpRequest();            
   		xmlHttp.open(getPost, urlFileAppl, trueFalse);
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {                 
	            if (xmlHttp.status == 200) {                
	            	showPathwayListAll(xmlHttp, comboName);
	            } else {
	                exceptionControl(xmlHttp);          
                	alertMessage("CODE: 2011");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
    }
    
    function showPathwayListAll(xmlHttp, comboName)
    {
    	var xmlData = xmlHttp.responseText;
    	var colsplit = xmlData.split("<T>");
    	//alert(colsplit.length);
    	var loadingOption = document.createElement("option");
    	loadingOption.innerHTML = 'Loading....<img src="images/indicator.gif">';
    	
   		var pathwayCombo = byId(comboName);
    	for(var i=0; i<colsplit.length-1; i++)
    	{
    		var newOption = document.createElement("option");
    		newOption.value = colsplit[i];
    		newOption.innerHTML = colsplit[i];    		
    		pathwayCombo.appendChild(newOption);
    	}
    } 

	function searchKeywordOfCondition()
	{
		if(byId("candidateCategory").value == 'Genetic')
		{
			byId('pathwayListDiv').style.visibility = 'visible';
			byId('pathwayListDiv').style.display = 'inline';
		}else{
			byId('pathwayListDiv').style.visibility = 'hidden';
			byId('pathwayListDiv').style.display = 'none';
		
			if(byId("candidateCategory").value != 'All'){
				var keywordBody = byId("candidateTableBody");
			  	deleteRowFromTable(keywordBody);
			  	var newRow = document.createElement("tr");
		  		var newCell = document.createElement("td");
		  		newCell.innerHTML = "Loading......<img src='images/indicator.gif'>";
		  		newRow.appendChild(newCell);
		  		keywordBody.appendChild(newRow);
	  		}
		}
	  	var sendData = "action=searchKeyword";
	  	var partialKey = "";
  		partialKey = byId("ConditionsearchKey").value;
	  	
	  	if(partialKey.length < 2 && byId("pathwayListCombo").value == 'All')
	  	{
	  		if(byId("candidateCategory").value == 'All')
	  			return;
	  	}
	  	
	  	sendData = sendData + "&category="+byId("candidateCategory").value;
	
	  	sendData = sendData + "&keyword="+partialKey;
	  	sendData = sendData + "&pid="+projectIdx;
	  	sendData = sendData + "&pathway="+byId("pathwayListCombo").value;
	  	var getPost = "POST";                      
	   	var urlFileAppl = "AnalysisServlet";
	   	var trueFalse = isTrueOrFalse;                       
	
	   	var xmlHttp = newXMLHttpRequest();
	  		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {              
	            if (xmlHttp.status == 200) {             
	            	//printPathwayList(xmlHttp);
	            	printConditionKeywordList(xmlHttp);
	            } else {
	                exceptionControl(xmlHttp);          
	                alert("CODE: 2012");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	 
	    xmlHttp.send(sendData);
	  	
	  	//End
  	}
  	function printConditionKeywordList(xmlHttp)
     {
       
  		var xmlData = xmlHttp.responseXML;
  	    
  		var rNodes = xmlData.getElementsByTagName("rname");
	  	var rGubun = xmlData.getElementsByTagName("rgubun");
	  	var rNames = xmlData.getElementsByTagName("roname");
	  	var rDescs = xmlData.getElementsByTagName("rdescription");
	  	
	  	var mNodes = xmlData.getElementsByTagName("mname");
	  	var mNames = xmlData.getElementsByTagName("moname");
	  	var mDescs = xmlData.getElementsByTagName("mdescription");
	  	var mGubun = xmlData.getElementsByTagName("mgubun");
	  	
	  	var keywordBody = byId("candidateTableBody");
	  	var i=0;
	  	for(i=keywordBody.rows.length-1; i>=0; i--)
	  		keywordBody.deleteRow(i);
	  	var k = 0;
	  	for(i=0; i<rNodes.length; i++)
	  	{
	  		var name = rNodes[i].childNodes[0].nodeValue;
	  		var gubun = rGubun[i].childNodes[0].nodeValue;
	  		var officialname = rNames[i].childNodes[0].nodeValue;
	  		var description = rDescs[i].childNodes[0].nodeValue;
	  		var newRow = document.createElement("tr");
	  		var newCell1 = document.createElement("td");
	  		var newCell2 = document.createElement("td");
	  		var newCell3 = document.createElement("td");
			var newCell4 = document.createElement("td");
			var newCell5 = document.createElement("td");
	  		newCell1.width = '20px';
	  		newCell2.width = '80px';
	  		newCell3.width = '250px';
	  		newCell4.width = '300px';
	  		newCell5.width = '50px';
	  		
			newRow.id = name;
			newCell1.innerHTML = i+1;
	  		newCell2.innerHTML = name;
	  		newCell3.innerHTML = officialname;
	  		newCell4.innerHTML = description;
	  		if(isExistCondition(name))
	  		{
	  	
	  			newCell5.innerHTML = "<input type=checkbox id=candidateChk_constraint"+k+" checked onClick='addOrDelCondition(\""+k+"\",\""+name+"\", \""+gubun+"\");'>";
	  		}
	  		else
	  		{
	  	
	  			newCell5.innerHTML = "<input type=checkbox id=candidateChk_constraint"+k+" onClick='addOrDelCondition(\""+k+"\",\""+name+"\", \""+gubun+"\");'>";
	  			
	  		}
	  		newRow.appendChild(newCell1);
	  		newRow.appendChild(newCell2);
	  		newRow.appendChild(newCell3);
	  		newRow.appendChild(newCell4);
	  		newRow.appendChild(newCell5);
	  		
	  		if((k % 2) == 0) newRow.bgColor = "#FFFFFF";
			if((k % 2) == 1) newRow.bgColor = "#eeeeee";
	  		
	  		keywordBody.appendChild(newRow);
	  		k++;
	  		//byId("searchConditionResultPane").style.visibility = "visible";
	  	}
	  	for(i=0; i<mNodes.length; i++)
	  	{
	  		
	  		var name = mNodes[i].childNodes[0].nodeValue;
	  		var gubun = mGubun[i].childNodes[0].nodeValue;
	  		var officialname = mNames[i].childNodes[0].nodeValue;
	  		var description = mDescs[i].childNodes[0].nodeValue;
	  		var newRow = document.createElement("tr");
	  		var newCell1 = document.createElement("td");
	  		var newCell2 = document.createElement("td");
	  		var newCell3 = document.createElement("td");
	  		var newCell4 = document.createElement("td");
	  		var newCell5 = document.createElement("td");

			newCell1.width = '20px';
	  		newCell2.width = '80px';
	  		newCell3.width = '250px';
	  		newCell4.width = '300px';
	  		newCell5.width = '50px';
	  		
			newRow.id = name;
	  		newCell1.innerHTML = i+1;
	  		newCell2.innerHTML = name;
	  		newCell3.innerHTML = officialname;
	  		newCell4.innerHTML = description;
	  		if(isExistCondition(name))
	  		{
	  			newCell5.innerHTML = "<input type=checkbox checked id=candidateChk_constraint"+k+" onClick='addOrDelCondition(\""+k+"\",\""+name+"\", \""+gubun+"\");'>";
	  		}
	  		else
	  		{
	  			newCell5.innerHTML = "<input type=checkbox id=candidateChk_constraint"+k+" onClick='addOrDelCondition(\""+k+"\",\""+name+"\", \""+gubun+"\");'>";
	  		}
	  		newRow.appendChild(newCell1);
	  		newRow.appendChild(newCell2);
	  		newRow.appendChild(newCell3);
	  		newRow.appendChild(newCell4);
	  		newRow.appendChild(newCell5);
	  		
	  		if((k % 2) == 0) newRow.bgColor = "#FFFFFF";
			if((k % 2) == 1) newRow.bgColor = "#eeeeee";
			
	  		keywordBody.appendChild(newRow);
	  		k++;
	  		//byId("searchConditionResultPane").style.visibility = "visible";
	  	}
  	}
  	function addOrDelCondition(key, word, gubun)
  	{
  	 // 
  		if(byId("candidateChk_constraint"+key).checked)
  		{
  		 
  			addCondition(word, gubun);
  			
  		}else{
  			var idx = getConstraintsIdx(word);
  		
  			if(idx >= 0) 
  			{
  			deleteConstraints(idx);
  			}
  		}
  	}
  	
  	function addOrDelObject(key, word, gubun)
  	{
  		
  		if(byId("candidateObjChk"+key).checked)
  		{
  			addObject(word, gubun);
  		}else{
  			var idx = getObjectsIdx(word);
  			if(idx >= 0) deleteObjects(idx);
  		}
  	}
  	
  	function addCondition(word, gubun) 
  	{
  		var sendData = "action=getInfo&keyword="+word+"&gubun="+gubun;
  		
	   	var getPost = "POST";                      
	   	var urlFileAppl = "AnalysisServlet";
	   	var trueFalse = isTrueOrFalse;                       
		//alert(sendData);
	   	var xmlHttp = newXMLHttpRequest();
	  	xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {              
	            if (xmlHttp.status == 200) {             
	            	saveCondition(xmlHttp);
	            } else {
	                exceptionControl(xmlHttp);          
	                alert("CODE:2013");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
	    
	  	//End
  	}
  	function saveCondition(xmlHttp)
  	{
  		var xmlData = xmlHttp.responseXML;
        
  		var cNodes = xmlData.getElementsByTagName("name");
	  
	  	var gNodes = xmlData.getElementsByTagName("gubun");
	  	var eNodes = xmlData.getElementsByTagName("equation");
	  	var conditionBody = byId("conditionBody");
	  	for(var i=0; i<cNodes.length; i++)
	  	{
	  		var name = cNodes[i].childNodes[0].nodeValue;
	  		
	  		var gubun = gNodes[i].childNodes[0].nodeValue;
	  		var equation = eNodes[i].childNodes[0].nodeValue;
	  		var conditionStr = "";
	  		if(equation.indexOf("<==>") >=0 || equation.indexOf("<-->") >=0 || equation.indexOf("==") >= 0)
	  		{
	  			conditionStr = name+"<T>"+equation+"<T>"+"-inf<T>"+"inf<T>"+"<T>"+gubun+"<T>";
	  			//alert("1"+conditionStr);
	  		}
	  		if(equation.indexOf("==>") >=0 || equation.indexOf("-->") >=0)
	  		{
                conditionStr = name+"<T>"+equation+"<T>"+"0<T>"+"inf<T>"+"<T>"+gubun+"<T>";
                                //alert("2"+conditionStr);
			}
			else
			{
	  			conditionStr = name+"<T>"+equation+"<T>"+"-inf<T>"+"inf<T>"+"<T>"+gubun+"<T>";
	  			//alert("3"+conditionStr);
	  		}
	  		
	  		constraints.push(conditionStr);
	  		
	  		printAddedCondition(conditionStr);
	  	}
	  	//byId("searchConditionResultPane").style.visibility = "hidden";
	  	byId("ConditionsearchKey").value = "";
  	}
  	
  	function printCondition(cPage)
  	{
  		conditionCnt = 0;
	  	var conditionBody = byId("conditionBody");
	  	deleteRowFromTable(conditionBody);
	  
	  	for(var i=0; i<constraints.length; i++)
	  	{
			var colSplit = constraints[i].split("<T>");
			if(byId("conditionGubun").value != 'A')
                                if(colSplit[5] != byId("conditionGubun").value) continue;

	  		conditionCnt++;
	  		//if(i < (cPage-1) * conditionCntForPage || i >= cPage * conditionCntForPage) continue;
	  		
			if(conditionCnt <=(cPage-1) * conditionCntForPage || conditionCnt >= (cPage) * conditionCntForPage+1) continue;
		
	  		var newRow = document.createElement("tr");
	  		newRow.id = conditionCnt;
	  		
	  		var newCell = [];
	  		for(var k=0; k<7; k++)
	  			newCell.push(document.createElement("td"));
	  	//	var colSplit = constraints[i].split("<T>");

	  		//if(byId("conditionGubun").value != 'A')
  			//	if(colSplit[5] != byId("conditionGubun").value) continue;
	  		
	  		newCell[0].innerHTML = i+1;
	  		
	  		newCell[1].innerHTML = colSplit[0];
 			if(colSplit[1].length > 5)
			{
	  			//newCell[2].innerHTML = colSplit[1].substring(0,15)+"......";
			 	newCell[2].innerHTML = "";
				newCell[2].innerHTML = newCell[2].innerHTML + "<img src='images/tip.gif' width=20 height=20  onmouseleave='hideUserTip();' onmouseover='showBalance(\""+colSplit[1]+"\",\"event\");' onmouseout='hideUserTip();'>";
			}
			else
				newCell[2].innerHTML = colSplit[1];
	  		newCell[3].innerHTML = "<input type=text id='lower"+i+"' size=10 value='"+colSplit[2]+"' onkeypress='onlyNumberAndINF();' onchange='changeConditionValue("+i+",2);' style='ime-mode:disabled' >";
	  		newCell[4].innerHTML = "<input type=text id='upper"+i+"' size=10 value='"+colSplit[3]+"' onkeypress='onlyNumberAndINF();' onchange='changeConditionValue("+i+",3);' style='ime-mode:disabled'>";
	  		newCell[5].innerHTML = "<input type=text id='measure"+i+"' size=10 value='"+colSplit[4]+"' onkeypress='onlyNumberAndINF();' onchange='changeConditionValue("+i+",4);' style='ime-mode:disabled'>";
	  		newCell[6].innerHTML = "<a href='javascript:changeConditionValueByAuto(\""+i+"\", \"I\");'>[Uptake]/</a>";
	  		newCell[6].innerHTML = newCell[6].innerHTML+"<a href='javascript:changeConditionValueByAuto(\""+i+"\", \"O\");'>[Secretion]</a>";
	  		if(byId('projectlist').value!=0) {
	  			newCell[6].innerHTML = newCell[6].innerHTML+"<a href='javascript:deleteConstraints("+i+");'>/Del</a>";	  		    
			}
			
	  		
	  		newCell[0].style.width = '40px';
	  		newCell[0].align = 'center';
	  		newCell[1].style.width = '100px';
	  		newCell[2].style.width = '100px';
	  		newCell[3].style.width = '100px';
	  		newCell[4].style.width = '100px';
	  		newCell[5].style.width = '100px';
	  		newCell[6].style.width = '100px';
	  		
	  		for(var k=0; k<7; k++) {
	  			newCell[k].style.borderBottomWidth = "1";
				newCell[k].style.borderBottomColor = "#eee";
				newCell[k].style.borderBottomStyle = "solid";
	  			newCell[k].style.borderRightWidth = "1";
				newCell[k].style.borderRightColor = "#eee";
				newCell[k].style.borderRightStyle = "solid";
		  		
		  		if((i % 2) == 0) newCell[k].bgColor = "#FFFFFF";
				if((i % 2) == 1) newCell[k].bgColor = "#eeeeee";
			
	  			newRow.appendChild(newCell[k]);
	  		}
				
	  		conditionBody.appendChild(newRow);
	  	}
  	}
	function showBalance(tipInfo,event)
	{
		if ( isIE == false )
        	{
        	
           		x =event.clientX
           		y =event.clientY;
          		 //alerddt(x+","+y);
        	}
        	else
        	{
           		x = window.event.clientX;
          	 	y = window.event.clientY;
       		 }
		var tipDlg = byId("userTip");
                var tipLen = tipInfo.length;
                tipDlg.style.height = (tipLen / 50)*20+20;

                tipDlg.innerHTML = "<center><table width='90%'><tr><td align=left>"+tipInfo+"</td></tr></table></center>";
                tipDlg.style.left = x+20;
                tipDlg.style.top = y-20;
                tipDlg.style.visibility = "visible";
                tipDlg.style.display = "inline";
	}
  	
  	function printAddedCondition(addedReaction)
  	{
  	  //  conditionCnt=0
	  	var conditionBody = byId('conditionBody');
	  	
  		var newRow = document.createElement("tr");
  		newRow.id = conditionCnt;
  		
  		conditionCnt++;
  		
  		var newCell = [];
  		for(var k=0; k<7; k++)
  			newCell.push(document.createElement("td"));
  		var colSplit = addedReaction.split("<T>");

  		if(byId('conditionGubun').value != 'A')
 				if(colSplit[5] != byId('conditionGubun').value) return;
 				
  		newCell[0].innerHTML = conditionCnt+1;
  		newCell[1].innerHTML = colSplit[0];
  		newCell[2].innerHTML = colSplit[1];
  		newCell[3].innerHTML = "<input type=text id='lower"+conditionCnt+"' size=3 value='"+colSplit[2]+"' onkeypress='onlyNumberAndINF();' onchange='changeConditionValue("+conditionCnt+",2);' style='ime-mode:disabled' >";
  		newCell[4].innerHTML = "<input type=text id='upper"+conditionCnt+"' size=3 value='"+colSplit[3]+"' onkeypress='onlyNumberAndINF();' onchange='changeConditionValue("+conditionCnt+",3);' style='ime-mode:disabled'>";
  		newCell[5].innerHTML = "<input type=text id='measure"+conditionCnt+"' size=3 value='"+colSplit[4]+"' onkeypress='onlyNumberAndINF();' onchange='changeConditionValue("+conditionCnt+",4);' style='ime-mode:disabled'>";
  		newCell[6].innerHTML = "<a href='javascript:deleteConstraints("+conditionCnt+");'>Del</a>";	  		
  		
  		newCell[0].style.width = '40px';
  		newCell[0].align = 'center';
  		newCell[1].style.width = '100px';
  		newCell[2].style.width = '300px';
  		newCell[3].style.width = '60px';
  		newCell[4].style.width = '60px';
  		newCell[5].style.width = '60px';
  		newCell[6].style.width = '60px';
  		//alert(colSplit[0]);
  		for(var k=0; k<7; k++) {
  			newCell[k].style.borderBottomWidth = "1";
			newCell[k].style.borderBottomColor = "#eee";
			newCell[k].style.borderBottomStyle = "solid";
  			newCell[k].style.borderRightWidth = "1";
			newCell[k].style.borderRightColor = "#eee";
			newCell[k].style.borderRightStyle = "solid";
	  		
	  		if((conditionCnt % 2) == 0) newCell[k].bgColor = "#FFFFFF";
			if((conditionCnt % 2) == 1) newCell[k].bgColor = "#eeeeee";
		
  			newRow.appendChild(newCell[k]);
  			
  		}
			
  		conditionBody.appendChild(newRow);
  		
  		
  		printCondition(conditionCurrentPage);
  		
  	}
  	
  	function deleteConstraints(idx)
  	{
  		//var response = confirm('Delete??');
   		//if(response) {
   			constraints.splice(idx,1);
   			printCondition(conditionCurrentPage);
   		//var tTable = byId("conditionBody");
   		//for(var i=0; i<tTable.rows.length; i++)
   		//{
   			//alert(tTable.rows[i].id);
   			//if(i==3) break;
   		//jk	if(idx == tTable.rows[i].id){
   		//		tTable.deleteRow(i);
   		//		break;
   		//	}
   		//}
   		//}
 	}
  	
  	function changeConditionValue(idx, col)
  	{
  		var changeValue = "";
  		if(col == 2) 
  			changeValue = byId("lower"+idx).value;
  		if(col == 3) 
  			changeValue = byId("upper"+idx).value;
  		if(col == 4) 
  			changeValue = byId("measure"+idx).value;
  			
  		for(var i=0; i<changeValue.length-1; i++)
  		{
  			var c = changeValue.substring(i,i+1);
  			if(!(c=='0'||c=='1'||c=='2'||c=='3'||c=='4'||c=='5'||c=='6'||c=='7'||c=='8'||c=='9'))
  			{
  				if(!(c == '-' || c == '.')){
  					if(c == 'i' || c == 'n' || c == 'f'){
  						if(!(changeValue == "-inf" || changeValue == "inf"))
		  				{
							if(col == 2) 
					  			byId("lower"+idx).value = '-inf';
					  		if(col == 3) 
					  			byId("upper"+idx).value = 'inf';
					  		if(col == 4) 
					  			byId("measure"+idx).value = '';		  				
					  		
					  		return;
		  				}
		  			}else return;
		  		}
  			}
  			
  		}
		
  		var colSplit = constraints[idx].split("<T>");
  		var conditionStr = "";
  		for(var i=0; i<colSplit.length; i++)
  		{  			
  			if(col == i) conditionStr = conditionStr + changeValue;
  			else conditionStr = conditionStr + colSplit[i];
  			if(i != colSplit.length-1) conditionStr = conditionStr+"<T>";
  		}
  		//alert(conditionStr);
  		constraints[idx] = conditionStr;
  	}
  	
  	function changeConditionValueByAuto(idx, gubun)
  	{
  		var lower = "-inf";
  		var upper = "inf";
  		//if(byId("kind"+idx).value = "U"){ //Unknown
  		if(gubun == "U"){ //Unknown
  			lower = "-inf";
  			upper = "inf";
  		//}else if(byId("kind"+idx).value = "I"){ //Uptake
  		}else if(gubun == "I"){ //Uptake
  			lower = "-inf";
  			upper = "0";
  		//}else if(byId("kind"+idx).value = "O"){ //Product
  		}else if(gubun == "O"){ //Product
  			lower = "0";
  			upper = "inf";
  		}
  		byId("lower"+idx).value = lower;
  		byId("upper"+idx).value = upper;
  			
  		var colSplit = constraints[idx].split("<T>");
  		var conditionStr = "";
  		for(var i=0; i<colSplit.length; i++)
  		{  			
  			if(i==2) conditionStr = conditionStr + lower;
  			else if(i==3) conditionStr = conditionStr + upper;
  			else conditionStr = conditionStr + colSplit[i];
  			if(i != colSplit.length-1) conditionStr = conditionStr+"<T>";
  		}
  		//alert(conditionStr);
  		constraints[idx] = conditionStr;
  	}
  	
  	function searchKeywordOfObject()
	{
		if(byId("candidateObjCategory").value == 'Genetic')
		{
			byId('pathwayListObjDiv').style.visibility = 'visible';
			byId('pathwayListObjDiv').style.display = 'inline';
		}else{
			byId('pathwayListObjDiv').style.visibility = 'hidden';
			byId('pathwayListObjDiv').style.display = 'none';
			
			if(byId("candidateObjCategory").value != 'All'){
				var keywordBody = byId("candidateObjTableBody");
			  	deleteRowFromTable(keywordBody);
			  	var newRow = document.createElement("tr");
		  		var newCell = document.createElement("td");
		  		newCell.innerHTML = "Loading......<img src='images/indicator.gif'>";
		  		newRow.appendChild(newCell);
		  		keywordBody.appendChild(newRow);
	  		}
		}
	  	var sendData = "action=searchKeyword";
	  	var partialKey = "";
  		partialKey = byId("ObjectsearchKey").value;
	  	
	  	if(partialKey.length < 2 && byId("pathwayListComboO").value == 'All')
	  	{
	  		if(byId("candidateObjCategory").value == 'All')
	  			return;
	  	}
	  	sendData = sendData + "&category="+byId("candidateObjCategory").value;
	  	
		//alert("11");
  		partialKey = byId("ObjectsearchKey").value;
	  	
	  	sendData = sendData + "&pid="+projectIdx;
	  	sendData = sendData + "&keyword="+partialKey;
	   	sendData = sendData + "&pathway="+byId("pathwayListComboO").value;
	   	var getPost = "POST";                      
	   	var urlFileAppl = "AnalysisServlet";
	   	var trueFalse = isTrueOrFalse;                       
	
	   	var xmlHttp = newXMLHttpRequest();
	  		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {              
	            if (xmlHttp.status == 200) {             
	            	//printPathwayList(xmlHttp);
	            	printObjectKeywordList(xmlHttp);
	            } else {
	                exceptionControl(xmlHttp);          
	                alert("CODE: 2014");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
	  	//End
  	}
  	function printObjectKeywordList(xmlHttp)
  	{
  		var xmlData = xmlHttp.responseXML;
  		var rNodes = xmlData.getElementsByTagName("rname");
	  	var rNames = xmlData.getElementsByTagName("roname");
	 
	  	var rDescs = xmlData.getElementsByTagName("rdescription");
	  	var rGubuns = xmlData.getElementsByTagName("rgubun");
	  	
	  	var mNodes = xmlData.getElementsByTagName("mname");
	  	var mNames = xmlData.getElementsByTagName("moname");
	  	var mDescs = xmlData.getElementsByTagName("mdescription");
	  	var mGubuns = xmlData.getElementsByTagName("mgubun");
	  	
	  	var keywordBody = byId("candidateObjTableBody");
	  	var i=0;
	  	for(i=keywordBody.rows.length-1; i>=0; i--)
	  		keywordBody.deleteRow(i);
	  	var k = 0;
	  
	  	for(i=0; i<rNodes.length; i++)
	  	{
	  		var name = rNodes[i].childNodes[0].nodeValue;
	  		var officialname = rNames[i].childNodes[0].nodeValue;
	  		var description = rDescs[i].childNodes[0].nodeValue;
	  		var gubun = rGubuns[i].childNodes[0].nodeValue;
	  		
	  		var newRow = document.createElement("tr");
	  		var newCell1 = document.createElement("td");
	  		var newCell2 = document.createElement("td");
	  		var newCell3 = document.createElement("td");
			var newCell4 = document.createElement("td");
			var newCell5 = document.createElement("td");
	  		
	  		newCell1.width = '20px';
	  		newCell2.width = '80px';
	  		newCell3.width = '250px';
	  		newCell4.width = '300px';
	  		newCell5.width = '50px';
	  		
			newRow.id = name;
			newCell1.innerHTML = i+1;
	  		newCell2.innerHTML = name;
	  		newCell3.innerHTML = officialname;
	  		newCell4.innerHTML = description;
	  		if(isExistObject(name))
	  			newCell5.innerHTML = "<input type=checkbox id=candidateObjChk"+k+" checked onClick='addOrDelObject(\""+k+"\",\""+name+"\", \""+gubun+"\");'>";
	  		else
	  			newCell5.innerHTML = "<input type=checkbox id=candidateObjChk"+k+" onClick='addOrDelObject(\""+k+"\",\""+name+"\", \""+gubun+"\");'>";
	  		
	  		newRow.appendChild(newCell1);
	  		newRow.appendChild(newCell2);
	  		newRow.appendChild(newCell3);
	  		newRow.appendChild(newCell4);
	  		newRow.appendChild(newCell5);
	  		keywordBody.appendChild(newRow);
	  		k++;
	  		//byId("searchConditionResultPane").style.visibility = "visible";
	  	}
	  	for(i=0; i<mNodes.length; i++)
	  	{
	  		
	  		var name = mNodes[i].childNodes[0].nodeValue;
	  		var officialname = mNames[i].childNodes[0].nodeValue;
	  		var description = mDescs[i].childNodes[0].nodeValue;
	  		var gubun = mGubuns[i].childNodes[0].nodeValue;
	  		
	  		var newRow = document.createElement("tr");
	  		var newCell1 = document.createElement("td");
	  		var newCell2 = document.createElement("td");
	  		var newCell3 = document.createElement("td");
	  		var newCell4 = document.createElement("td");
	  		var newCell5 = document.createElement("td");

			newCell1.width = '20px';
	  		newCell2.width = '80px';
	  		newCell3.width = '250px';
	  		newCell4.width = '300px';
	  		newCell5.width = '50px';
	  		
			newRow.id = name;
	  		newCell1.innerHTML = i+1;
	  		newCell2.innerHTML = name;
	  		newCell3.innerHTML = officialname;
	  		newCell4.innerHTML = description;
	  		if(isExistObject(name))
	  			newCell5.innerHTML = "<input type=checkbox checked id=candidateObjChk"+k+" onClick='addOrDelObject(\""+k+"\",\""+name+"\", \""+gubun+"\");'>";
	  		else
	  			newCell5.innerHTML = "<input type=checkbox id=candidateObjChk"+k+" onClick='addOrDelObject(\""+k+"\",\""+name+"\", \""+gubun+"\");'>";
	  		
	  		newRow.appendChild(newCell1);
	  		newRow.appendChild(newCell2);
	  		newRow.appendChild(newCell3);
	  		newRow.appendChild(newCell4);
	  		newRow.appendChild(newCell5);
	  		keywordBody.appendChild(newRow);
	  		k++;
	  		//byId("searchConditionResultPane").style.visibility = "visible";
	  	}
  	}
  	function addObject(word, gubun) 
  	{
		var sendData = "action=getInfo&keyword="+word+"&gubun="+gubun;
	   	var getPost = "POST";                      
	   	var urlFileAppl = "AnalysisServlet";
	   	var trueFalse = isTrueOrFalse;                       
	
	   	var xmlHttp = newXMLHttpRequest();
	  		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {              
	            if (xmlHttp.status == 200) {             
	            	saveObject(xmlHttp);
	            } else {
	                exceptionControl(xmlHttp);          
	                alert("CODE: 2015");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
	  	//End
  	}
  	function saveObject(xmlHttp)
  	{
  		var xmlData = xmlHttp.responseXML;
  		
  		var cNodes = xmlData.getElementsByTagName("name");
	  	var eNodes = xmlData.getElementsByTagName("equation");
	  	var gNodes = xmlData.getElementsByTagName("gubun");
	  	for(var i=0; i<cNodes.length; i++)
	  	{
	  		var name = cNodes[i].childNodes[0].nodeValue;
	  		var equation = eNodes[i].childNodes[0].nodeValue;
	  		var gubun = gNodes[i].childNodes[0].nodeValue;
	  		var regex = new RegExp("==",'g');
	  		equation = equation.replace(regex, "==");
	  		var objectStr = name+"<T>"+equation+"<T>MAX"+"<T>"+gubun+"<T>0";
	  		objectFunctions.push(objectStr);
	  	}
	  	//byId("searchObjectResultPane").style.visibility = "hidden";
	  	byId("ObjectsearchKey").value = "";
	  	printObject();
  	}
  	
  	function printObject()
  	{
	  	var objectBody = byId("objfuncTableBody");
	  	deleteRowFromTable(objectBody);
	  		
	  	for(var i=0; i<objectFunctions.length; i++)
	  	{
	  		var newRow = document.createElement("tr");
	  		newRow.id = i;
	  		
	  		var newCell = [];
	  		for(var k=0; k<5; k++)
	  			newCell.push(document.createElement("td"));
	  	
	  		newCell[0].style.width = '40px';
	  		newCell[1].style.width = '100px';
	  		newCell[2].style.width = '490px';
	  		newCell[3].style.width = '50px';
	  		newCell[4].style.width = '50px';
	  			
	  			
	  		var colSplit = objectFunctions[i].split("<T>");
	  		if(byId("objfunctionGubun").value != 'A')
  				if(colSplit[5] != byId("objfunctionGubun").value) continue;
	  		
	  		if(colSplit[4]=='1')
	  			newCell[0].innerHTML = "<input type=radio id=objectSelect name=objectSelect value="+i+" checked onClick='changeObjIdx("+i+");'> "+(i+1);
	  		else
	  		    newCell[0].innerHTML = "<input type=radio id=objectSelect name=objectSelect value="+i+"  onClick='changeObjIdx("+i+");'> "+(i+1);
	  		newCell[1].innerHTML = colSplit[0];
	  		newCell[2].innerHTML = colSplit[1];
	  		if(colSplit[2] == 'MAX'){
	  			newCell[3].innerHTML = "<input type=radio id='optimize+"+i+"' name='optimize+"+i+"' checked onClick='changeObjectValue("+i+", 2, \"MAX\");' value='MAX'>MAX";
	  			newCell[3].innerHTML = newCell[3].innerHTML+ "<input type=radio id='optimize+"+i+"' name='optimize+"+i+"' onClick='changeObjectValue("+i+", 2, \"MIN\");' value='MIN'>MIN";
	  		}
	  		else if(colSplit[2] == 'MIN'){
	  			newCell[3].innerHTML = "<input type=radio id='optimize+"+i+"' name='optimize+"+i+"' onClick='changeObjectValue("+i+", 2, \"MAX\");' value='MAX'>MAX";
	  			newCell[3].innerHTML = newCell[3].innerHTML+ "<input type=radio checked id='optimize+"+i+"' name='optimize+"+i+"' onClick='changeObjectValue("+i+", 2, \"MIN\");' value='MIN'>MIN";
	  		}
	  		newCell[4].innerHTML = "<a href='#' onClick='deleteObject("+i+");'>Del</a>";	  		
	  		
	  		for(var k=0; k<5; k++) newRow.appendChild(newCell[k]);
	  		
	  		objectBody.appendChild(newRow);
	  	}
  	}
  	
  	function changeObjIdx(idx)
  	{
  		objIdx = idx;
  	}
  	
  	function deleteObject(idx)
  	{
  		//var response = confirm('Delete??');
   		//if(response) {
   			objectFunctions.splice(idx,1);
   			printObject();
   		//}
  	}
  	
  	function deleteRowFromTable(rTableBody)
  	{
  		for(var i=rTableBody.rows.length-1; i>=0; i--)
	  		rTableBody.deleteRow(i);
  	}
  	
  	function changeObjectValue(idx, col, val)
  	{
  		var changeValue = val;
  		//if(col == 2) changeValue = byId("optimize"+idx).value;
  		//alert(idx+","+changeValue);
  		var colSplit = objectFunctions[idx].split("<T>");
  		var ObjectStr = "";
  		for(var i=0; i<colSplit.length; i++)
  		{  			
  			if(col == i) ObjectStr = ObjectStr + changeValue;
  			else ObjectStr = ObjectStr + colSplit[i];
  			if(i != colSplit.length-1) ObjectStr = ObjectStr+"<T>";
  		}
  		objectFunctions[idx] = ObjectStr;
  	}
  	
  	function startSovle()
  	{
  		var sendData = "action=resgiestPool";
	   	var getPost = "POST";                      
	   	var urlFileAppl = "AnalysisServlet";
	   	var trueFalse = isTrueOrFalse;                       
	
	   	var xmlHttp = newXMLHttpRequest();
	  		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {              
	            if (xmlHttp.status == 200) {             
	            	var sid = xmlHttp.responseText;
	            	waitingSolve(sid);
	            } else {
	                exceptionControl(xmlHttp);          
	                alert("CODE: 2031");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
  	}
  	function waitingSolve(sid)
  	{
  		var sendData = "action=getStatePool&sid="+sid;
	   	var getPost = "POST";                      
	   	var urlFileAppl = "AnalysisServlet";
	   	var trueFalse = true;                       
	
	   	var xmlHttp = newXMLHttpRequest();
	  		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {              
	            if (xmlHttp.status == 200) {             
	            	var wait = xmlHttp.responseText;
	            	//alert(wait);
	            	if(wait == '0'){
	            		byId("solveStatusSpan").innerHTML = "<font color=white>Solving...</font><img src='images/indicator.gif'>";
	            	 	sendCondtionAndObjFunc(sid);
	            	 }
	            	else if(wait == '1'){
	            		byId("solveStatusSpan").innerHTML = "<font color=white>Waiting...</font><img src='images/indicator.gif'>";
	            		self.setTimeout('waitingSolve('+sid+')',1000);
	            	}
	            	else {
	            		alert("Failed to Solve\nTry later again!!");
	            		byId("solveStatusSpan").innerHTML = "";
	            		return;
	            	}
	            } else {
	                exceptionControl(xmlHttp);          
	                alert("CODE: 2032");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
  	}
  	
  	function startSovleWithScript()
  	{
  		var sendData = "action=resgiestPool";
	   	var getPost = "POST";                      
	   	var urlFileAppl = "AnalysisServlet";
	   	var trueFalse = isTrueOrFalse;                       
	
	   	var xmlHttp = newXMLHttpRequest();
	  		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {              
	            if (xmlHttp.status == 200) {             
	            	var sid = xmlHttp.responseText;
	            	waitingSolveWithScript(sid);
	            } else {
	                exceptionControl(xmlHttp);          
	                alert("CODE: 2031");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
  	}
  	function waitingSolveWithScript(sid)
  	{
  		var sendData = "action=getStatePool&sid="+sid;
	   	var getPost = "POST";                      
	   	var urlFileAppl = "AnalysisServlet";
	   	var trueFalse = isTrueOrFalse;                       
	
	   	var xmlHttp = newXMLHttpRequest();
	  		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {              
	            if (xmlHttp.status == 200) {             
	            	var wait = xmlHttp.responseText;
	            	//alert(wait);
	            	if(wait == '0'){
	            		byId("solveStatusSpan").innerHTML = "<font color=black>Solving...</font><img src='images/indicator.gif'>";
	            	 	solveScript(sid);
	            	 }
	            	else if(wait == '1'){
	            		byId("solveStatusSpan").innerHTML = "<font color=black>Waiting...</font><img src='images/indicator.gif'>";
	            		self.setTimeout('waitingSolveWithScript('+sid+')',1000);
	            	}
	            	else {
	            		alert("Failed to Solve\nTry later again!!");
	            		byId("solveStatusSpan").innerHTML = "";
	            		return;
	            	}
	            } else {
	                exceptionControl(xmlHttp);          
	                alert("CODE: 2032");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
  	}
  	
  	function endingSolve(sid)
  	{
  		var sendData = "action=updatePool&sid="+sid;
	   	var getPost = "POST";                      
	   	var urlFileAppl = "AnalysisServlet";
	   	var trueFalse = true;                       
	
	   	var xmlHttp = newXMLHttpRequest();
	  		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {              
	            if (xmlHttp.status == 200) {             
	            	return;
	            } else {
	                exceptionControl(xmlHttp);          
	                alert("CODE: 2033");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
  	}
  	
  	function sendCondtionAndObjFunc(sid)
  	{
  		if(constraints.length < 1 || objectFunctions.length < 1)
  		{
  			//alert("There are no condition information!");
  			return;
  		}
  		//byId("solveStatusSpan").innerHTML = "<font color=white>Solving...</font><img src='images/indicator.gif'>";
	          //alert(conditionCurrentPage);  
	          if(conditionCurrentPage>1)
	          {
	             for(var m=0;m<conditionCurrentPage;m++)
	             {
	                 previousConditionPage();
	             }
	          }	 	
  		var sendData = "action=solve";
  		sendData = sendData + "&pid="+projectIdx;
  		//alert(sendData);
  	
  		for(var i=0; i<constraints.length; i++)
  		{
  			var colSplit = constraints[i].split("<T>");
  			sendData = sendData + "&cName"+i+"="+colSplit[0];
  			sendData = sendData + "&gubun"+i+"="+colSplit[5];
  			sendData = sendData + "&cL"+i+"="+colSplit[2];
  			sendData = sendData + "&cU"+i+"="+colSplit[3];
  			sendData = sendData + "&cM"+i+"="+colSplit[4];
  			
  		}
  		sendData = sendData + "&cCnt="+constraints.length;
  		
  		//alert(objIdx);
  		//var objIdx = byId("objectSelect").value;
  		var colSplit = objectFunctions[objIdx].split("<T>");
        var checker=colSplit[0].lastIndexOf("(e)");
        if(checker!=-1)
        {
        colSplit[1]=colSplit[1].replace(/^\s+/,""); 
        colSplit[1]=colSplit[1].replace(/\s+$/,""); 
        colSplit[1]=colSplit[1]+"(e)";
        sendData = sendData + "&oName="+colSplit[1];
  		sendData = sendData + "&oFunc="+colSplit[2];
  		sendData = sendData + "&oGubun="+colSplit[3];
        } 
        else
        {
  		sendData = sendData + "&oName="+colSplit[0];
  		sendData = sendData + "&oFunc="+colSplit[2];
  		sendData = sendData + "&oGubun="+colSplit[3];
  		}
  		//alert(sendData);
  		//return;
	   	var getPost = "POST";                      
	   	var urlFileAppl = "/AnalysisServlet";
	   	var trueFalse = isTrueOrFalse;                       
	
	   	var xmlHttp = newXMLHttpRequest();
	  		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {              
	            if (xmlHttp.status == 200) { 
	            	printResultFile(xmlHttp);
	            	endingSolve(sid);            
	            } else {
	                //exceptionControl(xmlHttp);          
	               // alert("CODE:2016");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);

  	}
  	
  	function printResultFile(xmlHttp)
  	{
  	  // selectPathwayForCategory("pathwayForResult", "all")
  	    var sel=document.getElementById('categoryResult');
  	    if(byId('projectlist').value=='0')
		     {
		       
		      
		       
		        sel.remove(8);
		     }
		   else if((byId('projectlist').value!='0')&&(byId('projectlist').value!='-1')&&(sel.length!=9))
		   {
		  
		     var sel1 = document.createElement('<option value="user">');
             document.all.categoryResult.options.add(sel1);
             sel1.innerText = "User Defined";
    
		   }
  	 
  		xmlData = xmlHttp.responseText;

  		var colSplit = xmlData.split("<T>");
  	
  		if(colSplit.length > 1)
  		{
  		   //alert(colSplit[0]);
  		    if(colSplit[0]=="null")
  		    {
  		     byId('solveStatusSpan').innerHTML = "<font color=black>"+"Unbound"+"</font>";
  		    }
  		    else
  		    {
  			byId('solveStatusSpan').innerHTML = "<font color=black>"+colSplit[0].substring(0, 6)+"</font>";
  		    }
  		
  			solveResultFile = colSplit[1];
  			//byId('lpscriptSource').value = colSplit[2];
  			//byId('saveresultBtn').disabled = false;
  			showAnalysisResult();
  			changeResultView();
  			showSolveResultSavePane('show');
  			
  			
  			
  		
  		}else{
  			byId('solveStatusSpan').innerHTML = "<font color=white>"+colSplit[0]+"</font>";
  			//alert("No Solution: "+colSplit[0]);
  			byId('lpscriptSource').value = colSplit[1];
  			byId('saveresultBtn').disabled = true;
  			showSolveResultSavePane('hide');
  			solveResultFile = '';
  			isShowResult = false;
  		}
  		
  	}
  	
  	function showSolveResultSavePane(gubun)
  	{
  	    
  		if(gubun == 'hide')
  		{
			byId('saveResultPane').style.visibility = 'hidden';
  			byId('saveResultPane').style.display = 'none';
  		}else{
  		  
  			byId('saveResultPane').style.visibility = 'visible';
  			byId('saveResultPane').style.display = 'inline';  		
  		}
  	}
  	
  	
  	
  	function saveCondtionAndObjFunc()
  	{
  		if(constraints.length < 1 || objectFunctions.length < 1)
  		{
  			alert("There are no Constraint/Objective Function information!");
  			return;
  		}
  		
  		var newName = '';
		var conditionid = '';
 		if(isNewAnalysis == 1)
 			newName = byId('newAnalysisName').value;
  		
  		for(var i=0; i < constraintSet.length; i++)
    		{	
    		    var colSplit = constraintSet[i].split("<T>");
    		    if(selectedAnalysis == colSplit[0]){
	    		newName = colSplit[1];
	    		conditionid = selectedAnalysis;
	    		}
    		}
		if(newName == ''){ 
                        alert("The name is empty!!"); 
                        return; 
                }
		//alert(newName);

  		var sendData = "action=savecondition";
  		sendData = sendData+"&conditionname="+newName;
  		if(conditionid != '') sendData = sendData+"&conditionid="+conditionid;
  		//alert(sendData);
  		for(var i=0; i<constraints.length; i++)
  		{
  		     
  			var colSplit = constraints[i].split("<T>");
  			sendData = sendData + "&cName"+i+"="+colSplit[0];
  			var m = -1;
  			m = colSplit[1].indexOf('+',m+1);
	  		while(m > 0)
	  		{
	  			k = m;
	  			colSplit[1] = colSplit[1].substring(0, m) + "#" +colSplit[1].substring(m+1, colSplit[1].length);
	  			m = colSplit[1].indexOf('+', m+1);
	  			if(m==k) break;
	  		}
  			sendData = sendData + "&cCom"+i+"="+colSplit[1];
  			sendData = sendData + "&gubun"+i+"="+colSplit[5];
  			sendData = sendData + "&cL"+i+"="+colSplit[2];
  			sendData = sendData + "&cU"+i+"="+colSplit[3];
  			sendData = sendData + "&cM"+i+"="+colSplit[4];
  		}
  		sendData = sendData + "&cCnt="+constraints.length;
  		
  		//alert(objIdx);
  		//var objIdx = byId("objectSelect").value;
  		for(var i=0; i<objectFunctions.length; i++)
  		{
	  		var colSplit = objectFunctions[i].split("<T>");
	  		sendData = sendData + "&oName"+i+"="+colSplit[0];
	  		var m = -1;
  			m = colSplit[1].indexOf('+',m+1);
	  		while(m > 0)
	  		{
	  			k = m;
	  			colSplit[1] = colSplit[1].substring(0, m) + "#" +colSplit[1].substring(m+1, colSplit[1].length);
	  			m = colSplit[1].indexOf('+', m+1);
	  			if(m==k) break;
	  		}
	  		sendData = sendData + "&oCom"+i+"="+colSplit[1];
	  		sendData = sendData + "&oFunc"+i+"="+colSplit[2];
	  		sendData = sendData + "&oGubun"+i+"="+colSplit[3];
	  		if(i == objIdx)
	  			sendData = sendData + "&oSel"+i+"=1";
	  		else
	  			sendData = sendData + "&oSel"+i+"=0";
  		}
  		sendData = sendData + "&oCnt="+objectFunctions.length;
  		
  		sendData = sendData + "&pid="+projectIdx;

  		//alert(sendData);
  		//return;
	   	var getPost = "POST";                      
	   	var urlFileAppl = "AnalysisServlet";
	   	var trueFalse = isTrueOrFalse;                       
	
	   	var xmlHttp = newXMLHttpRequest();
	  		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {              
	            if (xmlHttp.status == 200) {
	            	alert("Save completed!!");
	            	var newconditionId = xmlHttp.responseText;
	            	byId("saveasBtn").value = "Save As";
	            	byId("analysisName").innerHTML = "Condition for "+newName;
			//byId('newAnalysisName').value = newName;
	            	getAnalysisList();
	            	openCondition(newconditionId, projectIdx);
	            } else {
	                exceptionControl(xmlHttp);          
	                alert("CODE:2017");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
  	}
  	
  	function solveScript(sid)
  	{
  		byId('directsovleBtn').value = "Requesting...";
  		var sendData = "action=directsolve";
  		var script = byId('lpscriptSource').value;
  		var i = 0;
  		var k = 0;
  		i = script.indexOf('+',i+1);
  		while(i > 0)
  		{
  			k = i;
  			script = script.substring(0, i) + "#" +script.substring(i+1, script.length);
  			i = script.indexOf('+', i+1);
  			if(i==k) break;
  		}
  		
  		sendData = sendData +"&script="+script+"";
  		//alert(sendData);
  		//return;
	   	var getPost = "POST";                      
	   	var urlFileAppl = "AnalysisServlet";
	   	var trueFalse = isTrueOrFalse;                       
	
	   	var xmlHttp = newXMLHttpRequest();
	  		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	    	if(xmlHttp.readyState == 1)
	    		byId('solveStatusSpan').innerHTML = "Connecting...";
	    	if(xmlHttp.readyState == 2)
	    		byId('solveStatusSpan').innerHTML = "Requesting...";
	    	if(xmlHttp.readyState == 3)
	    		byId('solveStatusSpan').innerHTML = "Processing...";
	        if (xmlHttp.readyState == 4) {              
	            if (xmlHttp.status == 200) {
	            	printSolveResult(xmlHttp);
	                  
           	  		byId('directsovleBtn').value = "Solve";
           	  		byId("solveStatusSpan").innerHTML = "Ready";
           	  		endingSolve(sid);
	            } else {
	                exceptionControl(xmlHttp);          
	                alert("CODE:2018");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
  	}
  	
  	function printSolveResult(xmlHttp)
  	{
  		var xmlData = xmlHttp.responseText;
  		byId("lpscriptResult").value = xmlData;
  	}
  	
  	function deleteCondtionAndObjFunc()
  	{
  		var response = confirm('Delete??');
   		if(!response) {
   			return;
   		}
  		var idx = selectedAnalysis;
  		var sendData = "action=deletecondition";
  		sendData = sendData + "&conditionid="+idx;
  		sendData = sendData + "&pid="+projectIdx;

  		//alert(sendData);
  		//return;
	   	var getPost = "POST";                      
	   	var urlFileAppl = "AnalysisServlet";
	   	var trueFalse = isTrueOrFalse;                       
	
	   	var xmlHttp = newXMLHttpRequest();
	  		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {              
	            if (xmlHttp.status == 200) {
	            	deleteAnalysis(idx);  
	            	//alert("Delete completed!!");
	            	getAnalysisList();
	            	clearConditionTable();
	            } else {
	                exceptionControl(xmlHttp);          
	                alert("CODE:2019");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
  	}
  	
  	function clearConditionTable()
  	{
  		var conditionBody = byId("conditionBody");
	  	deleteRowFromTable(conditionBody);
	  	var objectBody = byId("objfuncTableBody");
	  	deleteRowFromTable(objectBody);
  	}
  	
  	function getConstraint(idx)
  	{
  		for(var i=0; i < constraintSet.length; i++)
    	{
    		var colSplit = constraintSet[i].split("<T>");
    		if(idx == colSplit[0]){
	    		return colSplit;
	    	}
    	}
  	}
  	
  	function changeOpenGubun()
  	{
  	    
  	    if(conditionCurrentPage>1)
	          {
	             for(var m=0;m<conditionCurrentPage;m++)
	             {
	                 previousConditionPage();
	             }
	          }	
	    conditionCurrentPage=1;      
  		printCondition(conditionCurrentPage);
  		printObject();
  	}
  	
  	function openCondition(idx, pidx)
  	{
  		if(idx == 1 && projectIdx == 0)
  		{
  			byId("saveBtn").disabled = true;
  			byId("saveasBtn").disabled = true;
  			byId("deleteBtn").disabled = true;
  		}else if(projectIdx > 0 && idx == 1)
  		{
  			byId("saveBtn").disabled = true;
  			byId("saveasBtn").disabled = false;
  			byId("deleteBtn").disabled = true;
  		}else{
  			byId("saveBtn").disabled = false;
  			byId("saveasBtn").disabled = false;
  			byId("deleteBtn").disabled = false;
  		}
  		byId('solveBtn').disabled = false;
  		
  		showAnalysis();
	  	deleteRowFromTable(byId("candidateTableBody"));
	  	deleteRowFromTable(byId("candidateObjTableBody"));
		  		
  		modelingGubun = 0;
  		
  		//if(selectedAnalysis == idx && projectIdx == pidx)
  		//{
  			//return;
  		//}
  		selectedAnalysis = idx;
  		isNewAnalysis = 0;
  		
  		var colSplit = getConstraint(idx);
		byId("analysisName").innerHTML = "Condition for "+colSplit[1]+" (modified at "+colSplit[2]+")";

		getConditionAndObjectList(idx, projectIdx);
		getConditionDescription();
  	}
  	
  	function getConditionAndObjectList(idx, projectIdx)
  	{
  		openConditionIdx = idx;
  		
  		var conditionBody = byId("conditionBody");
	  	deleteRowFromTable(conditionBody);
	  	var newRow = document.createElement("tr");
  		var newCell = document.createElement("td");
  		newCell.innerHTML = "Loading......<img src='images/indicator.gif'>";
  		newRow.appendChild(newCell);
  		conditionBody.appendChild(newRow);
  		
  		
  		var sendData = "action=getCondition";
  		sendData = sendData + "&conditionid="+idx;
  		sendData = sendData + "&pid="+projectIdx;
  		
  		//alert(sendData);
  		//return;
	   	var getPost = "POST";                      
	   	var urlFileAppl = "AnalysisServlet";
	   	var trueFalse = isTrueOrFalse;                       
	
	   	var xmlHttp = newXMLHttpRequest();
	  		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {              
	            if (xmlHttp.status == 200) {
	            	//alert("complete");
	            	saveAnalysisAndObject(xmlHttp);  
	            } else {
	                exceptionControl(xmlHttp);          
	                alert("CODE:2020");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
  	}
  	
  	function saveAnalysisAndObject(xmlHttp)
  	{
  		conditionCurrentPage = 1;
  		
  		var xmlData = xmlHttp.responseText;
  		var rowSplit = xmlData.split("<M>");
  		var con = rowSplit[0].split("<N>");
  		var obj = rowSplit[1].split("<N>");
  		
  		constraints = [];
  		objectFunctions = [];
  		
  		for(var i=0; i<con.length-1; i++)
	  	{
	  		constraints.push(con[i]);
	  	}
	  	conditionTotalPage = (constraints.length - (constraints.length % conditionCntForPage)) / conditionCntForPage + 1;
	  	for(var i=0; i<obj.length-1; i++)
	  	{
	  		objectFunctions.push(obj[i]);
	  	}
	  	printCondition(conditionCurrentPage);
	  	printObject();
  	}
  	
  	function nextConditionPage()
  	{
  		if(conditionTotalPage == conditionCurrentPage)
  		{
  			alert("This is Last Page!");
  			return;
  		}else{
  			conditionCurrentPage++;
  			printCondition(conditionCurrentPage);
  		}
  	}
  	 function regal()
      {
     if(conditionCurrentPage>1);
     {
        for(i=1;i<conditionCurrentPage;i++)
        {
            previousConditionPage();
        }
      }
      
   }
  	function previousConditionPage()
  	{
  		if(conditionCurrentPage != 0)
  		{
  			//alert("This is First Page!");
  			//return;
  		//}else{
  			conditionCurrentPage--;
  			printCondition(conditionCurrentPage);
  		}
  		else
  		{
  		 alert("This is First Page");
  		 }
  	   
  	}
  	
  	function changeCountForConditionPage()
  	{
  		conditionCntForPage = byId("countForConditionPage").value;
  		conditionTotalPage = (constraints.length - (constraints.length % conditionCntForPage)) / conditionCntForPage + 1;
  		if(conditionCurrentPage > conditionTotalPage) conditionCurrentPage = conditionTotalPage;
		printCondition(conditionCurrentPage);
  	}
  	
  	function nextResultPage()
  	{
  		if(resultTotalPage == resultCurrentPage)
  		{
  			alert("This is Last Page!");
  			return;
  		}else{
  			resultCurrentPage++;
  			if(byId("resultViewGubun").value == 'reaction')
  				makeTableDataWithResult("analysisResult", tempResultData, 0, 'reaction');
  			else
  				makeTableDataWithResult("analysisResult", tempResultData, 0, 'metabolite');
  		}
  	}
  	
  	function previousResultPage()
  	{
  		if(resultCurrentPage == 1)
  		{
  			alert("This is First Page!");
  			return;
  		}else{
  			resultCurrentPage--;
  			if(byId("resultViewGubun").value == 'reaction')
  				makeTableDataWithResult("analysisResult", tempResultData, 0, 'reaction');
  			else
  				makeTableDataWithResult("analysisResult", tempResultData, 0, 'metabolite');
  		}
  	}
  	
  	function changeCountForResultPage()
  	{
  		resultCntForPage = byId("countForResultPage").value;
  		resultTotalPage = (tempResultData.length - (tempResultData.length % resultCntForPage)) / resultCntForPage + 1;
  		if(resultCurrentPage > resultTotalPage) resultCurrentPage = resultTotalPage;

		if(byId("resultViewGubun").value == 'reaction')
			makeTableDataWithResult("analysisResult", tempResultData, 0, 'reaction');
		else
			makeTableDataWithResult("analysisResult", tempResultData, 0, 'metabolite');

  	}
  	
  	function newAnalysis()
  	{
  		showAnalysis();
  		byId("analysisName").innerHTML = "Condition: <input type=text id=newAnalysisName size=20>";
  		deleteRowFromTable(byId("objfuncTableBody"));
  		deleteRowFromTable(byId("conditionBody"));
  		isNewAnalysis = 1;
  		selectedAnalysis = -1;
  		removelAllArray(constraints);
  		removelAllArray(objectFunctions);
  		byId('saveasBtn').disabled = true;
  		byId('deleteBtn').disabled = true;
  		byId('solveBtn').disabled = true;
  		showConditionInfo('show');
  		byId("conditionDescription").readOnly = false;
  	}
  	
  	function removelAllArray(arr)
  	{
  		for(var i=arr.length-1; i>=0; i--)
  			arr.pop();
  	}
  	
  	function enterResultName()
  	{
  		if (event.keyCode != 13) return;
  		saveResult();
  	}
  	
  	function saveResult()
  	{
  		if(byId('saveName').disabled == true)
  		{
  			//byId('saveresultBtn').value = "Save";
  			byId('saveName').disabled = false;
  			//byId('saveName').size = 10;
  		
  			
  			return;
  		}else{
  		
	  		var saveName = byId('saveName').value;
	  		if(saveName == '')
	  		{
	  			alert('Please enter the name of result!!');
	  			byId('saveName').focus();
	  		}
	  		
	  		var sendData = "action=saveSolveResult";
	  		sendData = sendData + "&resultFile=tmp/"+solveResultFile;
	  		sendData = sendData + "&saveName="+saveName;
	  		sendData = sendData + "&pid="+projectIdx;
	  		sendData=sendData+"&username="+userid;
	        
	  		//alert(sendData);
	  		//return;
		   	var getPost = "POST";                      
		   	var urlFileAppl = "AnalysisServlet";
		   	var trueFalse = isTrueOrFalse;                       
		
		   	var xmlHttp = newXMLHttpRequest();
		  		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
		    xmlHttp.onreadystatechange = function() {    
		        if (xmlHttp.readyState == 4) {              
		            if (xmlHttp.status == 200) {
		            	getDataList(projectIdx,userid);  
				if(byId("FluxDataList").style.visibility == "hidden")
				{
				   //showOHideCompartive('FluxDataList');
				}
		            } else {
		                exceptionControl(xmlHttp);          
		                alert("CODE:2021");
		            }
		        }
		    }
		    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
		    xmlHttp.setRequestHeader("Content-Type", conType);
		    xmlHttp.send(sendData);
		    
		   // byId('saveresultBtn').value = "Save Result";
  			//byId('saveName').disabled = true;
  			byId('saveName').value = '';
  			//byId('saveName').size = 1;
  			showSolveResultSavePane();
		}
  	}
  	
  	function onlyNumber()
  	{
  		//alert(1);
  		var key = event.keyCode;
  		if(!(key==8||key==9||key==13||key==35||(key>=35&&key<=39)||key==45||key==46||key==144||(key>=48&&key<=57))){
			event.returnValue = true;
		}else{
		 	
		}	
  	}
  	
  	function onlyNumberAndINF()
  	{
  		//alert(1);
  		var key = event.keyCode;
  		if(!(key==8||key==9||key==13||key==35||(key>=35&&key<=39)||key==45||key==46||key==144||(key>=48&&key<=57))){
  			if((key==102||key==105||key==110)) // english char f, i, n
  				event.returnValue = true;
		 	else event.returnValue = false;
		}else{
		 	
		}	
  	}
  	
  	function saveAsCondtionAndObjFunc()
  	{
  		if(selectedAnalysis != -1)
  		{
			byId("analysisName").innerHTML = "New Condition Name: <input type=text id=newAnalysisName size=20>";
			byId("saveasBtn").value = "Cancel";
			byId("saveBtn").disabled = false;
			byId("deleteBtn").disabled = true;
	  		isNewAnalysis = 1;
	  		beforeselectedAnalysis = selectedAnalysis;
	  		selectedAnalysis = -1;
  		}else{
  			byId("saveasBtn").value = "Save As";
			byId("deleteBtn").disabled = false;
  			selectedAnalysis = beforeselectedAnalysis;
  			openCondition(beforeselectedAnalysis, projectIdx);
  			beforeselectedAnalysis = '';
  		}
  	}
  	
  	function getCandidateList()
  	{
  		
  	}
  	
  	function isExistCondition(id)
  	{
  		
  		for(var i=0; i<constraints.length; i++)
  		{ 
  			var colSplit = constraints[i].split("<T>");
  		
  			if(colSplit[0] == id) return true;
  		}
  		return false;
  	}
  	
  	function isExistObject(id)
  	{
  		
  		for(var i=0; i<objectFunctions.length; i++)
  		{ 
  			var colSplit = objectFunctions[i].split("<T>");
  			if(colSplit[0] == id) return true;
  		}
  		return false;
  	}
  	
  	function getConstraintsIdx(id)
  	{
  		for(var i=0; i<constraints.length; i++)
  		{ 
  			var colSplit = constraints[i].split("<T>");
  		
  			if(colSplit[0] == id) return i;
  			
  		}
  		return -1;
  	}
  	
  	function getObjectsIdx(id)
  	{
  		for(var i=0; i<objectFunctions.length; i++)
  		{ 
  			var colSplit = objectFunctions[i].split("<T>");
  			if(colSplit[0] == id) return i;
  		}
  		return -1;
  	}
  	
  	function showAnalysisConstraint()
	{
	    byId('chin').style.visibility = "visible";
		byId('chin').style.display = "inline";
		byId('condition').style.visibility = "visible";
		byId('condition').style.display = "inline";
       // byId("transporter").style.visibility = "hidden";
	//	byId("graphica").style.display = "hidden";
		byId('objfunc').style.visibility = "hidden";
		byId('LPScript').style.visibility = "hidden";
		byId("analysisResult").style.visibility = "hidden";
		byId("pathwayListDiv").style.visibility = "hidden";
		showAnalysisResultSub('hide');
		closeAddObjectDialog();
		
		byId("ListOfConstraintMenu").style.backgroundColor = "#F4A0A0";
		byId("ListOfObjectMenu").style.backgroundColor = "#ffffff";
		//byId("ListOfLPMenu").style.backgroundColor = "#ffffff";
		byId("ListOfResult").style.backgroundColor = "#ffffff";
	}
	function showAnalysisObject()
	{
	    byId("chin").style.visibility = "hidden";
		byId("chin").style.display = "none";
		byId("condition").style.visibility = "hidden";
		byId("condition").style.display = "none";
	//	byId("transporter").style.visibility = "hidden";
		//byId("graphica").style.display = "hidden";

		byId("objfunc").style.visibility = "visible";
		byId("objfunc").style.display = "inline";

		byId("LPScript").style.visibility = "hidden";
		byId("analysisResult").style.visibility = "hidden";
		byId("pathwayListObjDiv").style.visibility = "hidden";
		showAnalysisResultSub('hide');
		closeAddConstraintDialog();

		byId("ListOfConstraintMenu").style.backgroundColor = "#ffffff";
		byId("ListOfObjectMenu").style.backgroundColor = "#F4A0A0";
		//byId("ListOfLPMenu").style.backgroundColor = "#ffffff";
		byId("ListOfResult").style.backgroundColor = "#ffffff";
	}
	function showAnalysisScript()
	{
		byId("condition").style.visibility = "hidden";
		byId("condition").style.display = "none";

		byId("objfunc").style.visibility = "hidden";
		byId("objfunc").style.display = "none";

		byId("LPScript").style.visibility = "visible";
		byId("LPScript").style.display = "inline";

		byId("analysisResult").style.visibility = "hidden";
		showAnalysisResultSub('hide');
		closeAddConstraintDialog();
		closeAddObjectDialog();

		byId("ListOfConstraintMenu").style.backgroundColor = "#ffffff";
		byId("ListOfObjectMenu").style.backgroundColor = "#ffffff";
		//byId("ListOfLPMenu").style.backgroundColor = "#F4A0A0";
		byId("ListOfResult").style.backgroundColor = "#ffffff";
	}
	function showAnalysisResult()
	{
	 
	   byId("saveresultBtn").value = "Save";
	    byId("chin").style.visibility = "hidden";
		byId("chin").style.display = "none";
		byId("condition").style.visibility = "hidden";
		byId("condition").style.display = "none";
		byId("objfunc").style.visibility = "hidden";
		byId("objfunc").style.display = "none";
		byId("LPScript").style.visibility = "hidden";
		byId("LPScript").style.display = "none";
	  
	 if((byId("categoryResult").value!='--Subsystem All--')||(byId("pathwayForResult").value!='--PathwayAll--'))
      {
        byId("categoryResult").selectedIndex=0;
          selectPathwayForCategory('pathwayForResult','all');
        byId("pathwayForResult").selectedIndex=0;
      }
       
       
        //byId("transporter").style.visibility = "visible";
		//byId("graphica").style.display = "visible";
		byId("analysisResult").style.visibility = "visible";
		byId("analysisResult").style.display = "inline";
		byId("analysisControl").style.visibility = "visible";
		byId("analysisControl").style.display = "inline";
		
	    readyToGetCompoundWithAnalysisResult2();
	   
	   
		closeAddConstraintDialog();
		closeAddObjectDialog();
		
		showAnalysisResultSub('show');

		byId("ListOfConstraintMenu").style.backgroundColor = "#ffffff";
		byId("ListOfObjectMenu").style.backgroundColor = "#ffffff";
		//byId("ListOfLPMenu").style.backgroundColor = "#ffffff";
		byId("ListOfResult").style.backgroundColor = "#F4A0A0";
		
		readyToGetReactionWithAnalysisResult();
	}
	
	/*function showAnalysisResultSub(gubun)
	{
	   
		if(gubun == 'show')
		{
			if(byId("resultViewGubun").value == 'reaction' || byId("resultViewGubun").value == 'visualize')
				showCategoryResultDiv('show');
			else showCompoundResultDiv('show');
			if(byId("resultViewGubun").value == 'compound' || byId("resultViewGubun").value == 'reaction') 
				{
				showTableDivWithResult('show');
				changeResultView();
				}
			else 
			{
			showVisualizeDivWithResult('show');

			byId("saveResultPane").style.visibility = 'visible';
			}
		}else
		{
			showCategoryResultDiv('hide');
			showCompoundResultDiv('hide');
			showTableDivWithResult('hide');
			showVisualizeDivWithResult('hide');
			byId("saveResultPane").style.visibility = 'hidden';
		}
	}*/
	function showAnalysisResultSub(gubun)
	{
	   
		if(gubun == 'show')
		{
			if(byId('resultViewGubun').value == 'reaction')
			{
				showCategoryResultDiv('show');
				showCompoundResultDiv('hide');
				showTableDivWithResult('show');
				showTableDivWithResult1('hide');
				changeResultView();
			}
			else 
			{
			showCompoundResultDiv('show');
			showCategoryResultDiv('hide');
			showTableDivWithResult1('show');
			showTableDivWithResult('hide');
		    changeResultView();
			}
			
		   

			byId('saveResultPane').style.visibility = 'visible';
			
		}else
		{
			showCategoryResultDiv('hide');
			showCompoundResultDiv('hide');
			showTableDivWithResult('hide');
			showTableDivWithResult1('hide');
			showVisualizeDivWithResult('hide');
			byId('saveResultPane').style.visibility = 'hidden';
		}
	}
	
	
	/*function changeResultView()
	{
	   
	    overall.disable=false;
	    graphica.disable=false;
	    transporter.disable=false;
	    byId("ListOfResult").disabled=false;
		if(byId("resultViewGubun").value == "reaction")
		{
		    // byId("transporter").style.visibility='visible';
		     // byId("transporter").style.display = 'inline';
			showCategoryResultDiv('show');
			showCompoundResultDiv('hide');
          //  byId("graphica").style.visibility='visible';
        //      byId("graphica").style.display='inline';
			showTableDivWithResult('show');
			showVisualizeDivWithResult('hide');
			 overall.disabled=false;
			 graphica.disabled=false;
			
			//readyToGetReactionWithAnalysisResult();
		}else if(byId("resultViewGubun").value == "compound")
		{
		        // byId("graphica").style.visibility='hidden';
		      //  byId("graphica").style.display = 'none';
		      graphica.disabled=true;
		     //  byId("transporter").style.visibility='visible';
		     //  byId("transporter").style.display = 'inline';
		       
		    overall.disabled=false;
		    graphica.disabled=true;
			showCategoryResultDiv('hide');
			showCompoundResultDiv('show');

			showTableDivWithResult('show');
			showVisualizeDivWithResult('hide');
			
			readyToGetCompoundWithAnalysisResult();
		}
		else if(byId("resultViewGubun").value == "visualize")
		{
		 //  byId("transporter").style.visibility='hidden';
		 //   byId("transporter").style.display = 'none';
			showCategoryResultDiv('show');
			showCompoundResultDiv('hide');

			showTableDivWithResult('hide');
			showVisualizeDivWithResult('show');
			
			readyToGetReactionWithAnalysisResult();
		}		
	}*/
	function changeResultView()
	{
	  
	   // overall.disabled=false;
	   // graphica.disabled=true;
	    //transporter.disabled=false;
	    //byId('ListOfResult').disabled=false;
		if(byId('resultViewGubun').value == "reaction")
		{
		    // byId("transporter").style.visibility='visible';
		     // byId("transporter").style.display = 'inline';
			showCategoryResultDiv('show');
			showCompoundResultDiv('hide');
          //  byId("graphica").style.visibility='visible';
        //      byId("graphica").style.display='inline';
			showTableDivWithResult('show');
			showVisualizeDivWithResult('hide');
			// overall.disabled=false;
			// graphica.disabled=false;
			
			readyToGetReactionWithAnalysisResult();
		}
		else if(byId("resultViewGubun").value == "compound")
		{
		  
		        // byId("graphica").style.visibility='hidden';
		      //  byId("graphica").style.display = 'none';
		      //graphica.disabled=true;
		      showTableDivWithResult('hide');
		      showTableDivWithResult1('show');
		      showCompoundResultDiv('show');
		     //  byId("transporter").style.visibility='visible';
		     //  byId("transporter").style.display = 'inline';
		       
		   // overall.disabled=false;
		    //graphica.disabled=true;
			showCategoryResultDiv('hide');
			

			//showTableDivWithResult('show');
			//showVisualizeDivWithResult('hide');
			
			readyToGetCompoundWithAnalysisResult();
		}
		else if(byId("resultViewGubun").value == "visualize")
		{
		 //  byId("transporter").style.visibility='hidden';
		 //   byId("transporter").style.display = 'none';
			showCategoryResultDiv('show');
			showCompoundResultDiv('hide');

			showTableDivWithResult('hide');
			showVisualizeDivWithResult('show');
			
			readyToGetReactionWithAnalysisResult();
		}		
	}
	
	
	function showCompoundResultDiv(gubun){
		if(gubun == 'show'){
			byId("compoundResultDiv").style.visibility = 'visible';
			byId("compoundResultDiv").style.display = 'inline';
		}else{
			byId("compoundResultDiv").style.visibility = 'hidden';
			byId("compoundResultDiv").style.display = 'none';
		}
	}
	
	function showCategoryResultDiv(gubun){
		if(gubun == 'show'){
		   
			byId("categoryResultDiv").style.visibility = 'visible';
			byId("categoryResultDiv").style.display = 'inline';
		}else{
			byId("categoryResultDiv").style.visibility = 'hidden';
			byId("categoryResultDiv").style.display = 'none';
		}
	}
	
	/*function showTableDivWithResult(gubun){
		if(gubun == 'show'){
			byId("tableDivWithResult").style.visibility = 'visible';
			byId("tableDivWithResult").style.display = 'inline';
		}else{
			byId("tableDivWithResult").style.visibility = 'hidden';
			byId("tableDivWithResult").style.display = 'none';
		}
	}*/
	function showTableDivWithResult(gubun){
	 
	
		if(gubun == 'show'){
		
			byId("tableDivWithResult").style.visibility = 'visible';
			byId("tableDivWithResult").style.display = 'inline';
			byId("tableDivWithResult1").style.visibility = 'hidden';
			byId("tableDivWithResult1").style.display = 'none';
		}else{
			byId("tableDivWithResult").style.visibility = 'hidden';
			byId("tableDivWithResult").style.display = 'none';
			byId("tableDivWithResult1").style.visibility = 'visible';
			byId("tableDivWithResult1").style.display = 'inline';
		}
	}
	function showTableDivWithResult1(gubun){
	
		if(gubun == 'show'){
			byId("tableDivWithResult1").style.visibility = 'visible';
			byId("tableDivWithResult1").style.display = 'inline';
			byId("tableDivWithResult").style.visibility = 'hidden';
			byId("tableDivWithResult").style.display = 'none';
		}else{
			byId("tableDivWithResult1").style.visibility = 'hidden';
			byId("tableDivWithResult1").style.display = 'none';
			byId("tableDivWithResult").style.visibility = 'visible';
			byId("tableDivWithResult").style.display = 'inline';
		}
	}
	
	function showVisualizeDivWithResult(gubun){
		if(gubun == 'show'){
			deleteRowFromTable(byId("analysisResultTableBody"));
			byId("visualizeDivWithResult").style.visibility = 'visible';
			byId("visualizeDivWithResult").style.display = 'inline';
		}else{
			byId("visualizeDivWithResult").style.visibility = 'hidden';
			byId("visualizeDivWithResult").style.display = 'none';
		}
	}
	
	
    
    function makeModelWithAnalysisResult(pname)
    {
  
    	if(pname == ""){
    		//alert("There is no selected pathway!!");
    		return;
    	}else{
	    	var sendData = "cmd=visualize&name="+pname;
	    	var getPost = "POST";                      
	    	var urlFileAppl = "PathwayServlet";
	    	var trueFalse = isTrueOrFalse;                      
	
	    	var xmlHttp = newXMLHttpRequest();            
	   		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
		    xmlHttp.onreadystatechange = function() {    
		        if (xmlHttp.readyState == 4) {                 
		            if (xmlHttp.status == 200) {                
		            	var tFile = xmlHttp.responseText;
    					visualizeWithAnalysisResult(tFile);
		            } else {
		                exceptionControl(xmlHttp);           
		               alertMessage("Code: 2022");
		            }
		        }
		    }
		    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
		    xmlHttp.setRequestHeader("Content-Type", conType);
		    xmlHttp.send(sendData);
	    }
    }
    
    function visualizeWithAnalysisResult(tFile)
    {
         //byId("transporter").style.visibility='hidden';
	    //byId("transporter").style.display = 'none';
    	var fluxdata = "";
	    
    	var sendData = "cmd=data&modelfile="+tFile;
    	sendData = sendData + "&thickness="+thickness;
    	sendData = sendData + "&reaction="+reaction;
    	sendData = sendData + "&vertexSize="+vertexSize;
    	sendData = sendData + "&showcofactor="+showcofactor;
    	sendData = sendData + "&minvalue="+minvalue;
    	sendData = sendData + "&maxvalue="+maxvalue;
    	sendData = sendData + "&datafile=tmp/"+solveResultFile;
    	//alert(sendData);
		resultVisualization(sendData, solveResultFile);
    }
    
    function resultVisualization(sendData, message)
	{
	     var now = new Date();
         var seconds = now.getSeconds();
         var unit="nag"+seconds;
	    var win_ref2=window.open('visual_gan.html',unit, 'resizable=1,width=800,height=600,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
		var cont = "<img id='"+message+"' src='GraphServlet?"+sendData+"' border='0'>";
		//byId("visualizeAreaDivWithResult").innerHTML = cont;
		
		win_ref2.document.write(cont);
		
	}
    
    function readyToGetCompoundWithAnalysisResult()
    {
       
    	if(solveResultFile == '') return;
    	var sendData = "cmd=ConditionCompound&compartment="+byId("categoryCompoundResult").value;
		var fluxCnt = 1;
		sendData = sendData + "&condition0=tmp/"+solveResultFile;
		sendData = sendData +"&length="+fluxCnt;
		sendData=sendData+"&pid="+projectIdx;
 		var urlFileAppl = "PathwayServlet";
		
	  	deleteRowFromTable(byId("analysisResultTableBody"));
		var newRow = document.createElement("tr");
  		var newCell = document.createElement("td");
  		newCell.innerHTML = "Loading......<img src='images/indicator.gif'>";
  		newRow.appendChild(newCell);
  		byId("analysisResultTableBody").appendChild(newRow);
		getCompoundListWithResult(urlFileAppl, sendData);
       if(byId('resultViewGubun').value == 'compound' && byId('categoryCompoundResult').value == 'Extracellular'){
	  byId('overallReactionDiv').style.visibility = 'visible';
	  byId('overallReactionDiv').style.display = 'inline';	
	}
	//Modified By GANESH
	//else{
  	  //byId('overallReactionDiv').style.visibility = 'hidden';
        //  byId('overallReactionDiv').style.display = 'none';
	//}
    }
    //Written By Ganesh
  function readyToGetCompoundWithAnalysisResult1()
  {
    if(solveResultFile == '') return;
    	var sendData = "cmd=ConditionCompound&compartment=Extracellular";
		var fluxCnt = 1;
		sendData = sendData + "&condition0=tmp/"+solveResultFile;
		sendData = sendData +"&length="+fluxCnt;
		sendData=sendData+"&pid="+projectIdx;
 		var urlFileAppl = "PathwayServlet";
 		getCompoundListWithResult1(urlFileAppl, sendData);
  }
    function readyToGetCompoundWithAnalysisResult2()
  {
    if(solveResultFile == '') return;
    	var sendData = "cmd=ConditionCompound&compartment=Extracellular";
		var fluxCnt = 1;
		sendData = sendData + "&condition0=tmp/"+solveResultFile;
		sendData = sendData +"&length="+fluxCnt;
		sendData=sendData+"&pid="+projectIdx;
 		var urlFileAppl = "PathwayServlet";
 		getCompoundListWithResult2(urlFileAppl, sendData);
  }
    
    function getCompoundListWithResult(urlFileAppl, sendData)
    {
    	//informationdlg.hide();
    	var getPost = "POST";                     
    	var trueFalse = isTrueOrFalse;                      
		
    	var xmlHttp = newXMLHttpRequest();            
   		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {                 
	            if (xmlHttp.status == 200) {              
	            	showCompoundWithAnalysisResult(xmlHttp);
	            } else {
	                exceptionControl(xmlHttp);           
	                alertMessage("Code: 2023");
	            }
	            //progressdlg.hide();
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
    }
    //Implemented By Ganesh
    function getCompoundListWithResult1(urlFileAppl, sendData)
    {
       var getPost = "POST";                     
    	var trueFalse = isTrueOrFalse;                      
		
    	var xmlHttp = newXMLHttpRequest();            
   		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {                 
	            if (xmlHttp.status == 200) {              
	            	showCompoundWithAnalysisResult1(xmlHttp);
	            } else {
	                exceptionControl(xmlHttp);           
	                alertMessage("Code: 2023");
	            }
	            //progressdlg.hide();
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);

	    xmlHttp.send(sendData);
    }
    function getCompoundListWithResult2(urlFileAppl, sendData)
    {
       var getPost = "POST";                     
    	var trueFalse = isTrueOrFalse;                      
		
    	var xmlHttp = newXMLHttpRequest();            
   		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {                 
	            if (xmlHttp.status == 200) {              
	            	showCompoundWithAnalysisResult2(xmlHttp);
	            } else {
	                exceptionControl(xmlHttp);           
	                alertMessage("Code: 2023");
	            }
	            //progressdlg.hide();
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
       
	    xmlHttp.send(sendData);
    }
    function readyToGetReactionWithAnalysisResult()
    {
  
    // byId('overallReactionDiv').style.visibility = 'hidden';
          //byId('overallReactionDiv').style.display = 'none';
          //overall.disabled=true;
          //byId('transporter').style.visibility='visible';
        //if(byId("pathwayForResult").value=="--PathwayAll--")
        //{
       // selectPathwayForCategory("pathwayForResult","all");
        
       // }
        //else
        //{
    	if(solveResultFile == '') return;
    	if(byId("resultViewGubun").value == 'visualize')
    	{
    		var pname = byId("pathwayForResult").value;
    		makeModelWithAnalysisResult(pname);
    	}else{
    	
		byId("resultViewGubun").value = 'reaction';
		byId("categoryCompoundResult").value = 'Extracellular';
		 var val= byId("pathwayForResult").value;
		
		   if(val=="--PathwayAll--")
		   {
		     val="";
		   }
		 
		   //var num=val.lastIndexOf('<D>');
		  if((val!="")&&(val=="--PathwayAll--"))
		   {
		     //var fred=val.split("<D>");
		     //val=fred[0];
		    val=val;
		   
		   }
	    	var sendData = "cmd=ConditionReaction&pathway="+val;
	    	
	    	
			var fluxCnt = 1;
			sendData = sendData + "&condition0=tmp/"+solveResultFile;
			sendData = sendData +"&length="+fluxCnt;
			sendData=sendData+"&pid="+projectIdx;
	 		var urlFileAppl = "PathwayServlet";
			deleteRowFromTable(byId("analysisResultTableBody"));
			var newRow = document.createElement("tr");
	  		var newCell = document.createElement("td");
	  		newCell.innerHTML = "Loading......<img src='images/indicator.gif'>";
	  		newRow.appendChild(newCell);
	  		byId("analysisResultTableBody").appendChild(newRow);
			getReactionListWithResult(urlFileAppl, sendData);	
		}
		//}
    }
    function windowVisual()
    {
     var pname = byId("pathwayForResult").value;
     if(pname=="")
     {
       alert("Please select pathway");
     }
     else
     {
     makeModelWithAnalysisResult(pname);
     }
    }
    
    function getReactionListWithResult(urlFileAppl, sendData)
    {
    	//informationdlg.hide();
    	var getPost = "POST";                     
    	var trueFalse = isTrueOrFalse;                      
		
    	var xmlHttp = newXMLHttpRequest();            
   		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {                 
	            if (xmlHttp.status == 200) {              
	            	showReactionWithAnalysisResult(xmlHttp);
	            } else {
	                exceptionControl(xmlHttp);           
	                alertMessage("Code: 2024");
	            }
	            //progressdlg.hide();
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
    }
    
    function showReactionWithAnalysisResult(xmlHttp)
    {
    	
    	var xmlHttpData = xmlHttp.responseText;
    	
		tempResultData = xmlHttpData.split("<N>"); //Make a array of reaction list with flux		
		resultCurrentPage = 1;
		resultTotalPage = (tempResultData.length - (tempResultData.length % resultCntForPage)) / resultCntForPage + 1;

		makeTableDataWithResult("analysisResult", tempResultData, 0, 'reaction');
		//progressdlg.hide();
    }
    //Implemented By ganesh
     function showCompoundWithAnalysisResult1(xmlHttp)
     {
      var xmlHttpData = xmlHttp.responseText;
      
	  tempResultData1 = xmlHttpData.split("<N>"); //Make a array of reaction list with flux	
	   var leftR = "";
         var rightR = "";
		//if(byId("categoryCompoundResult").value != "Extracellular") {
			//return;
		//}
  		for(var i=0; i<tempResultData1.length-1; i++)
		{
	  		
			var colSplit = tempResultData1[i].split("<T>");
		   // alert(colSplit);
		 
			var fluxList = [];
			var colLen = 2;
			colLen = colSplit.length - 3;
			var flux = colSplit[2]*1;
			
			if(flux*1 < 0)
			{
			    
				if(leftR == "")
				{ 
				  flux=-(flux) 
					leftR = flux + " " + colSplit[0];
					
				}	
				else
				{
				    flux=-(flux) 
					leftR = leftR + " + " + flux + " " + colSplit[0];
					
					
				}
			}
			else if(flux*1 > 0)
			{
				if(rightR == "")
				{
					rightR = flux + " " + colSplit[0];
				}
				else
				{
					rightR = rightR + " + " + flux + " " + colSplit[0];
				}
			}				
		}
		if(window.clipboardData)
		{
		
			window.clipboardData.setData('Text', leftR+' ==> '+rightR);
		}
		alert(leftR + " ==> " + rightR);	
	  
		  
     }
     function showCompoundWithAnalysisResult2(xmlHttp)
     {
         var xmlHttpData = xmlHttp.responseText;
      
	  tempResultData1 = xmlHttpData.split("<N>"); //Make a array of reaction list with flux	
	   var leftR = "";
         var rightR = "";
		//if(byId("categoryCompoundResult").value != "Extracellular") {
			//return;
		//}
  		for(var i=0; i<tempResultData1.length-1; i++)
		{
	  		
			var colSplit = tempResultData1[i].split("<T>");
		   // alert(colSplit);
		 
			var fluxList = [];
			var colLen = 2;
			colLen = colSplit.length - 3;
			var flux = colSplit[2]*1;
			
			if(flux*1 < 0)
			{
			    
				if(leftR == "")
				{ 
				  flux=-(flux) 
					leftR = flux + " " + colSplit[0];
					
				}	
				else
				{
				    flux=-(flux) 
					leftR = leftR + " + " + flux + " " + colSplit[0];
					
					
				}
			}
			else if(flux*1 > 0)
			{
				if(rightR == "")
				{
					rightR = flux + " " + colSplit[0];
				}
				else
				{
					rightR = rightR + " + " + flux + " " + colSplit[0];
				}
			}				
		}
		
	    fair=leftR + " ==> " + rightR;	
		matrix();
			
	  
		  
     }
     function matrix()
     {
       return fair;
     }
    function showCompoundWithAnalysisResult(xmlHttp)
    {
    	var xmlHttpData = xmlHttp.responseText;
		tempResultData = xmlHttpData.split("<N>"); //Make a array of reaction list with flux
		//alert(tempResultData);		
		resultCurrentPage = 1;
		resultTotalPage = (tempResultData.length - (tempResultData.length % resultCntForPage)) / resultCntForPage + 1;
	  	
		makeTableDataWithResult("analysisResult", tempResultData, 0, 'metabolite');
		//progressdlg.hide();
    }
    
    function makeTableDataWithResult(tablename, rowSplit, isMapping, dataGubun)
    {
      
    	var TableBody = byId(tablename+"TableBody");

		for(var i=TableBody.rows.length-1; i>=0; i--)
			TableBody.deleteRow(i);
		
		if(tablename == "analysisResult") reactionList = rowSplit;
		for(var i=0; i<rowSplit.length-1; i++)
		{
			if(i < (resultCurrentPage-1) * resultCntForPage || i >= resultCurrentPage * resultCntForPage) continue;
	  		
			var colSplit = rowSplit[i].split("<T>");
			var fluxList = [];
			var newRow = makeNewRowWithResult(colSplit, i, tablename, dataGubun);
			newRow.id = tablename+"tr"+i;
			TableBody.appendChild(newRow);
			if(dataGubun == 'metabolite')
			{
				var nRow = document.createElement("tr");
				var nCol = document.createElement("td");
				nCol.colSpan = 2;
				nCol.id = tablename+"td"+i;
				//nCol.align ="right";
				nRow.appendChild(nCol);
				TableBody.appendChild(nRow);
			}
		}
    }
    
    function makeNewRowWithResult(colSplit, i, tablename, dataGubun)
    {
    
    	var newRow = document.createElement("tr");
		newRow.height = "20";
		newRow.style.backgroundColor = "#F8FFFF";
		var colLen = 2;
		if(tablename == 'analysisResult') 
		{
		    
			colLen = colSplit.length-2;
		}
		if(dataGubun == 'metabolite')
		{
			colLen = colSplit.length-3;
		}
		
    		for(var k=0; k<colLen-1; k++)
		  {
			var newCol = document.createElement("td");

			if(k > 1)	newCol.style.width = "80px";
			if(k == 0)	newCol.style.width = "120px";
			if(k == 1)	newCol.style.width = "250px";
			if(k == 2)	newCol.style.width = "80px";
			newCol.style.borderBottomWidth = "1";
			newCol.style.borderBottomColor = "#eee";
			newCol.style.borderBottomStyle = "solid";

			newCol.style.borderRightWidth = "1";
			newCol.style.borderRightColor = "#eee";
			newCol.style.borderRightStyle = "solid";

			newCol.innerHTML = "";
			if(k < 3)
			{
				if((i % 2) == 0) newCol.bgColor = "#FFFFFF";
				if((i % 2) == 1) newCol.bgColor = "#eeeeee";
				if(i == -1) newCol.bgColor = "#FFFACD";
			}
			if(k == 0) newCol.innerHTML = "&nbsp;"+ (i+1) + ". ";
			if((k>=2)&&(k<3)&&(dataGubun == 'metabolite'))
			{
			 var flux = colSplit[k];					
				if(flux > 0)
				{
					var bgco = "00";
					if(flux*1 > maxvalue*1)
					{ 
						flux = maxvalue;
					}else{
						bgco = makeHex(255 - flux * 255/maxvalue);
					}
					newCol.bgColor = "#FF"+bgco+bgco;
					if(flux/maxvalue > 0.7)
						newCol.innerHTML = newCol.innerHTML + "<font color=white>"+colSplit[k].substring(0,7)+"</font>";
					else
						newCol.innerHTML = newCol.innerHTML + colSplit[k].substring(0,7);
				}
				if(flux < 0)
				{
					var bgco = "00";
					if(flux*1 < minvalue*1)
					{
					 flux = minvalue;
					}else{
					 bgco = makeHex(255 - (flux * 255/minvalue));
					}
					newCol.bgColor = "#"+bgco+bgco+"FF";
					if(flux/minvalue > 0.7)
						newCol.innerHTML = newCol.innerHTML + "<font color=white>"+colSplit[k].substring(0,7)+"</font>";
					else
						newCol.innerHTML = newCol.innerHTML + colSplit[k].substring(0,7);
				}
				if(flux == 0)
				{
					newCol.bgColor = "#FFFFFF";
					newCol.innerHTML = newCol.innerHTML + colSplit[k];	
					
				}
			
			}
			else if((k >= 3)&&(dataGubun == 'reaction'))
			{
				var flux = colSplit[k];					
				if(flux > 0)
				{
					var bgco = "00";
					if(flux*1 > maxvalue*1)
					{ 
						flux = maxvalue;
					}else{
						bgco = makeHex(255 - flux * 255/maxvalue);
					}
					newCol.bgColor = "#FF"+bgco+bgco;
					if(flux/maxvalue > 0.7)
						newCol.innerHTML = newCol.innerHTML + "<font color=white>"+colSplit[k].substring(0,7)+"</font>";
					else
						newCol.innerHTML = newCol.innerHTML + colSplit[k].substring(0,7);
				}
				if(flux < 0)
				{
					var bgco = "00";
					if(flux*1 < minvalue*1)
					{
					 flux = minvalue;
					}else{
					 bgco = makeHex(255 - (flux * 255/minvalue));
					}
					newCol.bgColor = "#"+bgco+bgco+"FF";
					if(flux/minvalue > 0.7)
						newCol.innerHTML = newCol.innerHTML + "<font color=white>"+colSplit[k].substring(0,7)+"</font>";
					else
						newCol.innerHTML = newCol.innerHTML + colSplit[k].substring(0,7);
				}
				if(flux == 0)
				{
					newCol.bgColor = "#FFFFFF";
					newCol.innerHTML = newCol.innerHTML + colSplit[k];	
					
				}
			}else{
			   
				newCol.innerHTML = newCol.innerHTML + colSplit[k];
				//alert("SECOND"+newCol.innerHTML);
				
			} 					
			newRow.appendChild(newCol);
			
			if(k==1){ // Add columns for additional information
				
				if(dataGubun == 'reaction')
				{
						var nCol1 = document.createElement("td");
						nCol1.innerHTML = colSplit[colLen-1];
						if((i % 2) == 0) nCol1.bgColor = "#FFFFFF";
						if((i % 2) == 1) nCol1.bgColor = "#eeeeee";
						newRow.appendChild(nCol1);
				}
				if(dataGubun == 'metabolite')
				{
						var nCol = document.createElement("td");
					 
						nCol.innerHTML = colSplit[colLen-1];
						if((i % 2) == 0) nCol.bgColor = "#FFFFFF";
						if((i % 2) == 1) nCol.bgColor = "#eeeeee";
						newRow.appendChild(nCol);
				}
			}
		}
		return newRow;
    }
    
    function getDHTMLObject(name)
  	{
  		return byId(name);
  	}
  	
  	function openAddConstraintDialog()
  	{
  		byId('seachKeywordForConstraintDialog').style.visibility = 'visible';
		if(byId('conditionGubun').value == 'E')
		  byId('candidateCategory').options[0].selected = 'true';
                if(byId('conditionGubun').value == 'G')
                  byId('candidateCategory').options[1].selected = 'true';
		if(byId('conditionGubun').value == 'T')
                  byId('candidateCategory').options[2].selected = 'true';
		searchKeywordOfCondition();
  	}
  	
  	function closeAddConstraintDialog()
  	{
  		byId('seachKeywordForConstraintDialog').style.visibility = 'hidden';
  		byId("pathwayListDiv").style.visibility = 'hidden';
  		byId("candidateCategory").value = 'All';
  	}
  	
  	function openAddObjectDialog()
  	{
  		byId('seachKeywordForObjectDialog').style.visibility = 'visible';
  		
  	}
  	
  	function closeAddObjectDialog()
  	{
  		byId('seachKeywordForObjectDialog').style.visibility = 'hidden';
  		byId("pathwayListObjDiv").style.visibility = 'hidden';
  		byId("candidateObjCategory").value = 'All';
  	}
  	
  	function moveStartConstraintInput()
  	{
  		privX = event.x;
  		privY = event.y;
  		posX = byId("seachKeywordForConstraintDialog").style.left;
  		posY = byId("seachKeywordForConstraintDialog").style.top;
  		posX = posX.substring(0, posX.length-2);
  		posY = posY.substring(0, posY.length-2);
  	}
  	
  	function movingConstraintInput()
  	{
  	 	
  		var moveX = privX - event.x;
  		var moveY = privY - event.y;
  		var destY = (new Number(posY) - new Number(moveY));
  		var destX = (new Number(posX) - new Number(moveX));
  		if(destX <-400) destX = -400;
  		if(destY <100) destY = 100;
  		if(destX >150) destX = 150;
  		if(destY >550) destY = 550;
  		
  		byId("seachKeywordForConstraintDialog").style.top = destY+"px";
  		byId("seachKeywordForConstraintDialog").style.left = destX+"px";
  	}
  	
  	function moveStartObjectInput()
  	{
  		privX = event.x;
  		privY = event.y;
  		posX = byId("seachKeywordForObjectDialog").style.left;
  		posY = byId("seachKeywordForObjectDialog").style.top;
  		posX = posX.substring(0, posX.length-2);
  		posY = posY.substring(0, posY.length-2);
  	}
  	function moveConstraintForm(direction)
  	{
  		posX = byId("seachKeywordForConstraintDialog").style.left;
  		posY = byId("seachKeywordForConstraintDialog").style.top;
  		posX = posX.substring(0, posX.length-2);
  		posY = posY.substring(0, posY.length-2);
  		
  		var destY = posY;
  		var destX = posX;
  		
  		if(direction == 'up'){
  			destY = (new Number(posY) - 100);
  		}
  		if(direction == 'down'){
  			destY = (new Number(posY) + 100);  		
  		}
  		if(direction == 'left'){
  			destX = (new Number(posX) - 100);  		
  		}
  		if(direction == 'right'){
  			destX = (new Number(posX) + 100);  		
  		}

  		if(destX <-400) destX = -400;
  		if(destY <100) destY = 100;
  		if(destX >150) destX = 150;
  		if(destY >550) destY = 550;
  		
  		byId("seachKeywordForConstraintDialog").style.top = destY+"px";
  		byId("seachKeywordForConstraintDialog").style.left = destX+"px";
  	}
  	
  	function movingObjectInput()
  	{
  	 	
  		var moveX = privX - event.x;
  		var moveY = privY - event.y;
  		var destY = (new Number(posY) - new Number(moveY));
  		var destX = (new Number(posX) - new Number(moveX));
  		if(destX <-400) destX = -400;
  		if(destY <100) destY = 100;
  		if(destX >150) destX = 150;
  		if(destY >550) destY = 550;
  		
  		byId("seachKeywordForObjectDialog").style.top = destY+"px";
  		byId("seachKeywordForObjectDialog").style.left = destX+"px";
  	}
  	function moveObjectForm(direction)
  	{
  		posX = byId("seachKeywordForObjectDialog").style.left;
  		posY = byId("seachKeywordForObjectDialog").style.top;
  		posX = posX.substring(0, posX.length-2);
  		posY = posY.substring(0, posY.length-2);
  		
  		var destY = posY;
  		var destX = posX;
  		
  		if(direction == 'up'){
  			destY = (new Number(posY) - 100);
  		}
  		if(direction == 'down'){
  			destY = (new Number(posY) + 100);  		
  		}
  		if(direction == 'left'){
  			destX = (new Number(posX) - 100);  		
  		}
  		if(direction == 'right'){
  			destX = (new Number(posX) + 100);  		
  		}

  		if(destX <-400) destX = -400;
  		if(destY <100) destY = 100;
  		if(destX >150) destX = 150;
  		if(destY >550) destY = 550;
  		
  		byId("seachKeywordForObjectDialog").style.top = destY+"px";
  		byId("seachKeywordForObjectDialog").style.left = destX+"px";
  	}
  	
  	function showConditionInfo(gubun)
  	{
  		if(gubun == 'show'){
			byId('conditionInfoDiv').style.visibility = 'visible';
  			byId("conditionInfoDiv").style.display = 'inline';
  			if(isNewAnalysis == 1) byId("conditionDescription").readonly = false;  			
			byId('AnalysisPane').style.height = '750px';
  		}else{
			byId('conditionInfoDiv').style.visibility = 'hidden';
	  		byId("conditionInfoDiv").style.display = 'none';
			byId('AnalysisPane').style.height = '690px';
  		}
  	}
  	
  	function getConditionDescription()
  	{
  		if(selectedAnalysis == 1) {
  			byId("conditionDescription").readOnly = true;
  		//	byId("condtionSaveBtn").disabled = true;
  		}else{
  			byId("conditionDescription").readOnly = false;
  		//	byId("condtionSaveBtn").disabled = false;
  		}
  		var pid = projectIdx;
		var cidx = selectedAnalysis;
		
		var sendData = "";
		sendData = sendData+"action=getconditionDesc&pid="+pid;
		sendData = sendData+"&cidx="+cidx;
	   	
	   	var getPost = "POST";                     
	   	var urlFileAppl = "AnalysisServlet";
	   	var trueFalse = isTrueOrFalse;                       
	   	var xmlHttp = newXMLHttpRequest();            
	  		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {                 
	            if (xmlHttp.status == 200) {               
	            	byId("conditionDescription").value = xmlHttp.responseText;
	            } else {
	                exceptionControl(xmlHttp);            
	                alertMessage("Code: 2025");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
  	}
  	
  	function saveConditionDescription()
  	{
  		var pid = projectIdx;
		var cidx = selectedAnalysis;
		var description = byId("conditionDescription").value;
		var name = byId("newAnalysisName").value;
		if(description == '')
		{
			alert("Description is empty");
			return;
		}
		
		var sendData = "";
		sendData = sendData+"action=saveconditionDesc&pid="+pid;
		sendData = sendData+"&cidx="+cidx;
		sendData = sendData + "&description="+description;
		sendData = sendData + "&name="+name;
	   	
	   	var getPost = "POST";                     
	   	var urlFileAppl = "AnalysisServlet";
	   	//var trueFalse = isTrueOrFalse;
		var trueFalse = false;
	   	var xmlHttp = newXMLHttpRequest();            
	  		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {                 
	            if (xmlHttp.status == 200) {               
	            	alert("Saved");
	            } else {
	                exceptionControl(xmlHttp);            
	                alertMessage("Code: 2020");
	            }
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
	    //alert(sendData);
  	}

  	function makeOverallReaction()
  	{
  	    readyToGetCompoundWithAnalysisResult1();
		
  	}

	function showOverallReaction()
	{
		//alert(makeOverallReaction());
		 
		makeOverallReaction();
	}
