	var compareTotalPage = 1;
	var compareCurrentPage = 1;
	var compareCntForPage = 20;
	
  function ChangeOptions2()
  {
  		minvalue = byId("minvalue2").value;
  		maxvalue = byId("maxvalue2").value;
  		//getSystemInformation(pathwayName, previousCategory);
  		changeCompareView();
  }
	function selectPathwayForCompare()
	{
		var cat = byId('categoryCompare').value;
		if(cat=='all')
								   {
								      byId('visio').disabled=true;
								   }
								   else
								   {
								     byId('visio').disabled=false;
								   }
		selectPathwayForCategory('pathwayForCompareCombo', cat);
		
	}

	function showComparetiveAnalysis()
	{
		selectPathwayForCompare();
		
		 var sel=document.getElementById("categoryCompare");
  	    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.categoryCompare.options.add(sel1);
             sel1.innerText = "User Defined";
    
		   }
		if(byId("compare").style.visibility != "visible"){
			byId("compare").style.visibility = "visible";
			byId("compareResult").style.visibility = "visible";
			changeCompareView();
		}
	}
	
	function changeCompareView()
	{
	    showVisualizeDivWithCompare('show');
		if(byId("compareViewGubun").value == "reaction")
		{
			showCategoryCompareDiv('show');
			showCompoundCompareDiv('hide');
            showVisualizeDivWithCompare("show");
			showTableDivWithCompare('show');
			
			//Changed By Ganesh
			showVisualizeDivWithCompare('show');
			
			readyToGetReactionWithAnalysisCompare();
		}else if(byId("compareViewGubun").value == "compound")
		{
		    byId("visio").disabled=true;
			showCategoryCompareDiv('hide');
			showCompoundCompareDiv('show');
            showVisualizeDivWithCompare("show");
			showTableDivWithCompare('show');
			//Changes By Ganesh
			showVisualizeDivWithCompare('show');
			
			readyToGetCompoundWithAnalysisCompare();
		}else if(byId("compareViewGubun").value == "visualize")
		{
			showCategoryCompareDiv('show');
			showCompoundCompareDiv('hide');

			showTableDivWithCompare('hide');
			
			
			if(byId("pathwayForCompareCombo").value != ''){
				makeModelWithAnalysisCompare(byId("pathwayForCompareCombo").value);
			}
		}		
	}

	
	function showCompoundCompareDiv(gubun){
		if(gubun == 'show'){
			byId("compoundCompareDiv").style.visibility = "visible";
			byId("compoundCompareDiv").style.display = "inline";
		}else{
			byId("compoundCompareDiv").style.visibility = "hidden";
			byId("compoundCompareDiv").style.display = "none";
		}
	}
	
	function showCategoryCompareDiv(gubun){
		if(gubun == 'show'){
			byId("categoryCompareDiv").style.visibility = "visible";
			byId("categoryCompareDiv").style.display = "inline";
		}else{
			byId("categoryCompareDiv").style.visibility = "hidden";
			byId("categoryCompareDiv").style.display = "none";
		}
	}
	
	function showTableDivWithCompare(gubun){
		if(gubun == 'show'){
			byId("tableDivWithCompare").style.visibility = "visible";
			byId("tableDivWithCompare").style.display = "inline";
		}else{
			byId("tableDivWithCompare").style.visibility = "hidden";
			byId("tableDivWithCompare").style.display = "none";
		}
	}
	
	function showVisualizeDivWithCompare(gubun){
		if(gubun == "show"){
			deleteRowFromTable(byId("compareAnalysisTableBody"));
			byId("visualizeDivWithCompare").style.visibility = "visible";
			byId("visualizeDivWithCompare").style.display = "inline";
		}else{
			byId("visualizeDivWithCompare").style.visibility = "hidden";
			byId("visualizeDivWithCompare").style.display = "none";
		}
	}
	
	function makeModelWithAnalysisCompare(pname)
    {
    	if(pname == ""){
    		//alert("There is no selected pathway!!");
    		return;
    	}else{
	    	var sendData = "cmd=visualize&name="+pname;
	    	sendData = sendData + "&pid="+projectIdx;
	    	var getPost = "POST";                      
	    	var urlFileAppl = "PathwayServlet";
	    	var trueFalse = true;                      
	
	    	var xmlHttp = newXMLHttpRequest();            
	   		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
		    xmlHttp.onreadystatechange = function() {    
		        if (xmlHttp.readyState == 4) {                 
		            if (xmlHttp.status == 200) {                
		            	var tFile = xmlHttp.responseText;
    					visualizeWithAnalysisCompare(tFile);
		            } else {
		                exceptionControl(xmlHttp);           
		               alertMessage("Code: 4001");
		            }
		        }
		    }
		    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
		    xmlHttp.setRequestHeader("Content-Type", conType);
		    xmlHttp.send(sendData);
	    }
    }
    
    function visualizeWithAnalysisCompare(tFile)
    {
    
    	var fluxdata = "";
	    
    	var sendData = "cmd=datas&modelfile="+tFile;
    	var dataCnt = 0;
    	for(var i=0; i<conditionData.length; i++)
    	{
    		if(!byId("fluxCombo"+i).checked) continue;
   			dataCnt = dataCnt + 1;
   			sendData = sendData + "&datafile"+dataCnt+"="+conditionData[i];
    	}
    	if(dataCnt > 1)
    		sendData = sendData + "&thickness=0";
    	else
    	    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 + "&dataCnt="+dataCnt;
    	//alert(sendData);
		compareVisualization(sendData, "Comparision");
    }
    
    function compareVisualization(sendData, message)
	{
		//var cont = "<img id='"+message+"' src='GraphServlet?"+sendData+"' border='0'>";
		//alert(cont);
		var win_ref3=window.open('viscompare.html','welcome2','resizable=1,width=880,height=650,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes');
		var cont = "<img id='"+message+"' src='GraphServlet?"+sendData+"' border='0'>";
		//byId("visualizeAreaDivWithCompare").innerHTML = cont;
		win_ref3.document.write(cont);
	}
    
    function readyToGetCompoundWithAnalysisCompare()
    {
   
    	var sendData = "cmd=ConditionCompound&compartment="+byId("categoryCompoundCompare").value;
		var fluxCnt = 0;
		for(var i=0; i<conditionData.length; i++)
		{
			if(!byId("fluxCombo"+i).checked) continue;   				
			sendData = sendData + "&condition"+fluxCnt+"="+conditionData[i];
			
			fluxCnt++;
		}
		sendData = sendData +"&length="+fluxCnt;
 		var urlFileAppl = "PathwayServlet";
 		
 		//alert(sendData);
		getCompoundListWithCompare(urlFileAppl, sendData);
		
	  	deleteRowFromTable(byId("compareAnalysisTableBody"));
		var newRow = document.createElement("tr");
  		var newCell = document.createElement("td");
  		newCell.innerHTML = "Loading......<img src='images/indicator.gif'>";
  		newRow.appendChild(newCell);
  		byId("compareAnalysisTableBody").appendChild(newRow);
    }
    
    function getCompoundListWithCompare(urlFileAppl, sendData)
    {
    	//informationdlg.hide();
    	var getPost = "POST";                     
    	var trueFalse = true;                      
		
    	var xmlHttp = newXMLHttpRequest();            
   		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {                 
	            if (xmlHttp.status == 200) {              
	            	showCompoundWithAnalysisCompare(xmlHttp);
	            } else {
	                exceptionControl(xmlHttp);           
	                alertMessage("Code: 4002");
	            }
	            //progressdlg.hide();
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
    }
    
    function readyToGetReactionWithAnalysisCompare()
    {
    	if(byId("compareViewGubun").value == 'visualize')
    	{
    		var pname = byId("pathwayForCompareCombo").value;
    		makeModelWithAnalysisCompare(pname);
    	}else{
    	    var dog=byId("pathwayForCompareCombo").value;
    	    if(dog=='--PathwayAll--')
    	    {
    	      dog="";
    	      byId('visio').disabled=true;
    	    }
    	    else
    	    {
    	     byId('visio').disabled=false;
	    	}
	    	var sendData = "cmd=ConditionReaction1&pathway="+dog;
	    	sendData=sendData+"&pid="+projectIdx
			var fluxCnt = 0;
  				for(var i=0; i<conditionData.length; i++)
   			{
   				if(!byId("fluxCombo"+i).checked) continue;   				
   				sendData = sendData + "&condition"+fluxCnt+"="+conditionData[i];
   				fluxCnt++;
   			}
  			sendData = sendData +"&length="+fluxCnt;
   			//alert(sendData);
			var urlFileAppl = "PathwayServlet";
			getReactionListWithCompare(urlFileAppl, sendData);
			
			deleteRowFromTable(byId("compareAnalysisTableBody"));
			var newRow = document.createElement("tr");
	  		var newCell = document.createElement("td");
	  		newCell.innerHTML = "Loading......<img src='images/indicator.gif'>";
	  		newRow.appendChild(newCell);
	  		byId("compareAnalysisTableBody").appendChild(newRow);
		}
    }
    
    function getReactionListWithCompare(urlFileAppl, sendData)
    {
    	//informationdlg.hide();
    	var getPost = "POST";                     
    	var trueFalse = true;                      
		
    	var xmlHttp = newXMLHttpRequest();            
   		xmlHttp.open(getPost, urlFileAppl, trueFalse); 
	    xmlHttp.onreadystatechange = function() {    
	        if (xmlHttp.readyState == 4) {                 
	            if (xmlHttp.status == 200) {              
	            	showReactionWithAnalysisCompare(xmlHttp);
	            } else {
	                exceptionControl(xmlHttp);           
	                alertMessage("Code: 4003");
	            }
	            //progressdlg.hide();
	        }
	    }
	    var conType = "application/x-www-form-urlencoded; charset=UTF-8";
	    xmlHttp.setRequestHeader("Content-Type", conType);
	    xmlHttp.send(sendData);
    }
    
    function showReactionWithAnalysisCompare(xmlHttp)
    {
    	
    	var xmlHttpData = xmlHttp.responseText;
    	
		tempResultData = xmlHttpData.split("<N>"); //Make a array of reaction list with flux		
		compareCurrentPage = 1;
		compareTotalPage = (tempResultData.length - (tempResultData.length % compareCntForPage)) / compareCntForPage + 1;
	  	
	  	makeTableDataWithCompare("compareAnalysis", tempResultData, 0, 'reaction');
		//progressdlg.hide();
    }
    
    function showCompoundWithAnalysisCompare(xmlHttp)
    {
    	var xmlHttpData = xmlHttp.responseText;
		tempResultData = xmlHttpData.split("<N>"); //Make a array of reaction list with flux		
		compareCurrentPage = 1;
		compareTotalPage = (tempResultData.length - (tempResultData.length % compareCntForPage)) / compareCntForPage + 1;
	  	
	  	
		makeTableDataWithCompare("compareAnalysis", tempResultData, 0, 'metabolite');
		//progressdlg.hide();
    }
    
    function makeTableDataWithCompare(tablename, rowSplit, isMapping, dataGubun)
    {
    	//alert(rowSplit);
    	var TableHead = byId(tablename+"TableHead");
		var TableBody = byId(tablename+"TableBody");

		for(var i=TableHead.rows[0].cells.length-1; i>1; i--)
			TableHead.rows[0].deleteCell(i);

		//var colCnt = 0;
		if(dataGubun == 'reaction')
		{
			if(byId('showReactionNameInCompare').checked)
			{
				var newth = document.createElement("th");
				newth.innerHTML = 'Official Name';
				newth.width = "120px";
				TableHead.rows[0].appendChild(newth);
			}
			if(byId('showReactionECInCompare').checked)
			{
				var newth = document.createElement("th");
				newth.innerHTML = 'EC-Number';
				newth.width = "100px";
				TableHead.rows[0].appendChild(newth);
			}
		}
		if(dataGubun == 'metabolite')
		{
			if(byId('showCompoundNameInCompare').checked)
			{
				var newth = document.createElement("th");
				newth.innerHTML = 'Official Name';
				newth.width = "120px";
				TableHead.rows[0].appendChild(newth);
			}
			if(byId('showCompoundFormulaInCompare').checked)
			{
				var newth = document.createElement("th");
				newth.innerHTML = 'Formula';
				newth.width = "100px";
				TableHead.rows[0].appendChild(newth);
			}
			if(byId('showCompoundChargeInCompare').checked)
			{
				var newth = document.createElement("th");
				newth.innerHTML = 'Charge';
				newth.width = "100px";
				TableHead.rows[0].appendChild(newth);
			}
		}
		
				for(var i=0; i<conditionData.length; i++)
				{
					if(!byId("fluxCombo"+i).checked) continue;
					var newth = document.createElement("th");
					newth.innerHTML = conditions[i];
					newth.width = "60px";
					//newth.innerHTML = newth.innerHTML+ " <a href='#' onClick='javascript:makeModel(\""+i+"\");'>[V]</a></div>";
					TableHead.rows[0].appendChild(newth);
					//colCnt++;
				}
		//byId("lhtab1").style.width = 500 + 60*colCnt;
		for(var i=TableBody.rows.length-1; i>=0; i--)
			TableBody.deleteRow(i);

		if(dataGubun == "reaction") reactionList = rowSplit;
		for(var i=0; i<rowSplit.length-1; i++)
		{
			if(i < (compareCurrentPage-1) * compareCntForPage || i >= compareCurrentPage * compareCntForPage) continue;
			
			var colSplit = rowSplit[i].split("<T>");
			var fluxList = [];
			var newRow = makeNewRowWithCompare(colSplit, i, tablename, dataGubun);
			newRow.id = tablename+"tr"+i;
			//newRow.setAttribute("onClick",new Function("showDetailInformation("+tablename+"tr"+i+")"));  
			TableBody.appendChild(newRow);
			if(dataGubun == 'metabolite')
			{
				var nRow = document.createElement("tr");
				var nCol = document.createElement("td");
				nCol.colSpan = conditionData.length+2;
				nCol.id = tablename+"td"+i;
				//nCol.align ="right";
				nRow.appendChild(nCol);
				TableBody.appendChild(nRow);
			}
		}
    }
    
    function makeNewRowWithCompare(colSplit, i, tablename, dataGubun)
    {
    	//alert(colSplit);
    	var newRow = document.createElement("tr");
		newRow.height = "20";
		newRow.style.backgroundColor = "#F8FFFF";
		var colLen = 2;
		if(dataGubun == 'reaction')
		{
			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 = "60px";
			if(k == 0)	newCol.style.width = "110px";
			if(k == 1)	newCol.style.width = "250px";
			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 < 2)
			{
				if((i % 2) == 0) newCol.bgColor = "#FFFFFF";
				if((i % 2) == 1) newCol.bgColor = "#eeeeee";
				if(i == -1) newCol.bgColor = "#FFFACD";
			}
			if(k == 0 && (dataGubun == 'reaction' || dataGubun == 'metabolite')) newCol.innerHTML = "&nbsp;"+ (i+1) + ". ";
			if(k >= 2)
			{
				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);
				}else 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);
				}else //if(flux == 0)
				{
					newCol.bgColor = "#FFFFFF";
					newCol.innerHTML = newCol.innerHTML + colSplit[k];				
				}
			}else{
				//alert(k+":"+colSplit[k]);
				newCol.innerHTML = newCol.innerHTML + colSplit[k];
				if(k == 1 && dataGubun == 'metabolite')
				{
					//newCol.innerHTML = "<div id='"+tablename+"div"+i+"' style='cursor:hand;' onClick='showDetailInformation(\""+i+"\", \""+tablename+"\", \""+colSplit[k]+"\", \""+colSplit[0]+"\");'>"+colSplit[k]+ "</div>";	
				}
			} 				
			newRow.appendChild(newCol);
			
			if(k==1){ // Add columns for additional information
				
				if(dataGubun == 'reaction')
				{
					if(byId('showReactionNameInCompare').checked)
					{
						var nCol = document.createElement("td");
						nCol.innerHTML = colSplit[colLen-1];
						nCol.width = "120px";
						if((i % 2) == 0) nCol.bgColor = "#FFFFFF";
						if((i % 2) == 1) nCol.bgColor = "#eeeeee";
						newRow.appendChild(nCol);
					}
					if(byId('showReactionECInCompare').checked)
					{
						var nCol = document.createElement("td");
						nCol.innerHTML = colSplit[colLen];
						nCol.width = "100px";
						if((i % 2) == 0) nCol.bgColor = "#FFFFFF";
						if((i % 2) == 1) nCol.bgColor = "#eeeeee";
						newRow.appendChild(nCol);
					}
				}
				if(dataGubun == 'metabolite')
				{
					if(byId('showCompoundNameInCompare').checked)
					{
						var nCol = document.createElement("td");
						nCol.innerHTML = colSplit[colLen-1];
						nCol.width = "120px";
						if((i % 2) == 0) nCol.bgColor = "#FFFFFF";
						if((i % 2) == 1) nCol.bgColor = "#eeeeee";
						newRow.appendChild(nCol);
					}
					if(byId('showCompoundFormulaInCompare').checked)
					{
						var nCol = document.createElement("td");
						nCol.innerHTML = colSplit[colLen];
						nCol.width = "100px";
						if((i % 2) == 0) nCol.bgColor = "#FFFFFF";
						if((i % 2) == 1) nCol.bgColor = "#eeeeee";
						newRow.appendChild(nCol);
					}
					if(byId('showCompoundChargeInCompare').checked)
					{
						var nCol = document.createElement("td");
						nCol.innerHTML = colSplit[colLen+1];
						nCol.width = "100px";
						if((i % 2) == 0) nCol.bgColor = "#FFFFFF";
						if((i % 2) == 1) nCol.bgColor = "#eeeeee";
						newRow.appendChild(nCol);
					}
				}
			}
		}
		//alert(1);
		
		return newRow;
    }
    
    function showFieldSelectInCompare()
  	{
  		var x = "200px";
  		var y = "80px";
  		if(isIE){
  			x = event.x-180;
  		}
  		if(getDHTMLObject("compareViewGubun").value == "reaction")
	  		showFieldSelectDivInCompare('showReactionFieldInCompare', x, y);
	  	if(getDHTMLObject("compareViewGubun").value == "compound")
	  		showFieldSelectDivInCompare('showCompoundFieldInCompare', x, y);
	  	if(getDHTMLObject("compareViewGubun").value == "visualize")
	  		showFieldSelectDivInCompare("optionsInCompare2", x, y);
  	}
  	
  	function showFieldSelectDivInCompare(divBody, x, y)
	{
		if(byId(divBody).style.visibility == 'visible'){
			byId(divBody).style.visibility = 'hidden';
			byId(divBody).style.display = 'none';
		}else{
			byId(divBody).style.visibility = 'visible';
			byId(divBody).style.display = 'inline';
			byId(divBody).style.left = x;
			byId(divBody).style.top = y;
		}
	}
	function changeOptionInCompare()
    {
    	if(byId("thicknessInCompare").checked) thickness = 1;
	  	else thickness = 0;
	  	
	  	if(byId("vertexSizeInCompare").checked) vertexSize = 1;
	  	else vertexSize = 0;
	  	
	  	if(byId("reactionInCompare").checked) reaction = 1;
	  	else reaction = 0;
	  	
	  	if(byId("showcofactorInCompare").checked) showcofactor = 1;
	  	else showcofactor = 0;
    }
    
    function nextComparePage()
  	{
  		if(compareTotalPage == compareCurrentPage)
  		{
  			alert("This is Last Page!");
  			return;
  		}else{
  			compareCurrentPage++;
  			if(byId("compareViewGubun").value == 'reaction')
  				makeTableDataWithCompare("compareAnalysis", tempResultData, 0, 'reaction');
  			else
  				makeTableDataWithCompare("compareAnalysis", tempResultData, 0, 'metabolite');
  		}
  	}
  	
  	function previousComparePage()
  	{
  		if(compareCurrentPage == 1)
  		{
  			alert("This is First Page!");
  			return;
  		}else{
  			compareCurrentPage--;
  			if(byId("compareViewGubun").value == 'reaction')
  				makeTableDataWithCompare("compareAnalysis", tempResultData, 0, 'reaction');
  			else
  				makeTableDataWithCompare("compareAnalysis", tempResultData, 0, 'metabolite');
  		}
  	}
  	
  	function changeCountForComparePage()
  	{
  		compareCntForPage = byId("countForComparePage").value;
  		compareTotalPage = (tempResultData.length - (tempResultData.length % compareCntForPage)) / compareCntForPage + 1;
  		if(compareCurrentPage > compareTotalPage) compareCurrentPage = compareTotalPage;
		if(byId("compareViewGubun").value == 'reaction')
			makeTableDataWithCompare("compareAnalysis", tempResultData, 0, 'reaction');
		else
			makeTableDataWithCompare("compareAnalysis", tempResultData, 0, 'metabolite');

  	}
    