var masterMixRequirements = {
    card: 1,
    plate: 10,
    fastplate: 10,
    wellplate96: 10,
    wellplate384: 5,
    tubes: 10
};
var listHtml = "";
var sortedBy = 1;
var tubeCustomRec = null;
var plateCustomRec = null;
var plateFixedRec = null;
var cardCustomRec = null;
var cardFixedRec = null;
var openArrayCustomRec = null;
var openArrayFixedRec = null;
var costChartStore = Ext.create('Ext.data.JsonStore', {
    fields: ['name', 'assay', 'mastermix', 'optimization', 'total', 'index', 'blank', 'title', 'pno'],
    data: [{
            name: '',
            assay: 0,
            mastermix: 0,
            optimization: 0,
            total: 0,
            index: 0,
            blank: ' ',
            title: ' ',
            pno: 0
        }, {
            name: '',
            assay: 0,
            mastermix: 0,
            optimization: 0,
            total: 0,
            index: 1,
            blank: ' ',
            title: ' ',
            pno: 0
        }, {
            name: '',
            assay: 0,
            mastermix: 0,
            optimization: 0,
            total: 0,
            index: 2,
            blank: ' ',
            title: ' ',
            pno: 0
        }, {
            name: '',
            assay: 0,
            mastermix: 0,
            optimization: 0,
            total: 0,
            index: 3,
            blank: ' ',
            title: ' '
        }, {
            name: '',
            assay: 0,
            mastermix: 0,
            optimization: 0,
            total: 0,
            index: 4,
            blank: ' ',
            title: ' ',
            pno: 0
        }, {
            name: '',
            assay: 0,
            mastermix: 0,
            optimization: 0,
            total: 0,
            index: 5,
            blank: ' ',
            title: ' ',
            pno: 0
        }, {
            name: '',
            assay: 0,
            mastermix: 0,
            optimization: 0,
            total: 0,
            index: 6,
            blank: ' ',
            title: ' ',
            pno: 0
        }, {
            name: '',
            assay: 0,
            mastermix: 0,
            optimization: 0,
            total: 0,
            index: 7,
            blank: ' ',
            title: ' ',
            pno: 0
        }
    ]
});
var timeChartStore = Ext.create('Ext.data.JsonStore', {
    fields: ['name', 'time', 'index', 'title', 'pno'],
    data: [{
            name: '',
            time: 0,
            index: 0,
            title: ' ',
            pno: 0
        }, {
            name: '',
            time: 0,
            index: 1,
            title: ' ',
            pno: 0
        }, {
            name: '',
            time: 0,
            index: 2,
            title: ' ',
            pno: 0
        }, {
            name: '',
            time: 0,
            index: 3,
            title: ' ',
            pno: 0
        }, {
            name: '',
            time: 0,
            index: 4,
            title: ' ',
            pno: 0
        }, {
            name: '',
            time: 0,
            index: 5,
            title: ' ',
            pno: 0
        }, {
            name: '',
            time: 0,
            index: 6,
            title: ' ',
            pno: 0
        }, {
            name: '',
            time: 0,
            index: 7,
            title: ' ',
            pno: 0
        }
    ]
});
var colors = ['url(#v-1)', 'url(#v-2)', 'url(#v-3)'];
Ext.define('Ext.chart.theme.Fancy', {
    extend: 'Ext.chart.theme.Base',
    constructor: function (config) {
        this.callParent([Ext.apply({
                colors: colors
            }, config)]);
    }
});
var chartRendered = false;
var sybr = null;
var osybr = null;
var osybrf = null;
var isFixed = null;

function clearChartData() {
    for (var i = 0; i < costChartStore.getCount(); i++) {
        costChartStore.getAt(i).set('name', '');
        costChartStore.getAt(i).set('assay', 0);
        costChartStore.getAt(i).set('mastermix', 0);
        costChartStore.getAt(i).set('optimization', 0);
        costChartStore.getAt(i).set('total', 0);
        timeChartStore.getAt(i).set('name', '');
        timeChartStore.getAt(i).set('time', 0);
    }
}

function processOutputList(fixedChkChanged) {
	
	warningEMessageArray = [];
	if (fixedChkChanged) {
        clearChartData();
    }
    if (Ext.get('fixedcontfilter').dom.checked) {
        Ext.get('fixedconttxt').addCls('hidden');
        // if(!chartDisplayed && isFixed != null && !isFixed) {
        // return;
    } else {
        Ext.get('fixedconttxt').removeCls('hidden');
        // if(!chartDisplayed && isFixed != null && isFixed) {
        // return;
        // }
    }
    outputList.removeAll(true);
    showEditButton();
	
    if (getExperimentInfo("type") == "Genotyping") {
		$('#sybrsec').hide();
		var anyinstrument = $( "#anyinstrument" ).hasClass( "tbuttonselected" );
		var techboth = $( "#techboth" ).hasClass( "tbuttonselected" );
		if(anyinstrument && techboth){
			addDigitalGenoTyping(false);
			//addDigitalGenoTyping(true);
		}
		if(getExperimentInfo("openarrayinstrument") === "QS3D"){
			addDigitalGenoTyping(false);
			//addDigitalGenoTyping(true);
		}else{
			var isQuant = getExperimentInfo('openarrayinstrument') == "QuantStudio" ? true : false;
			if (Ext.get('fixedcontfilter').dom.checked) {
				addOGTAPF();
				addOGTAPFS();
				addOPGP();
				if( isQuant ) {
					addOPGEP();
				}
				addOGTAPFSall();
			}
			addGenoTubeCustom();
			addGenoTubeInventoried();
			addGenoTubeMadeToOrder();
			addOGTAPC();
			addOGTABEAPC();
		}
    } else if (getExperimentInfo("type") == "Copy Number") {
		$('#sybrsec').hide();
        Ext.get('emessage').addCls('hidden');
		var anyinstrument = $( "#anyinstrument" ).hasClass( "tbuttonselected" );
		var techboth = $( "#techboth" ).hasClass( "tbuttonselected" );
		if(anyinstrument && techboth){
			addDigitalCopyNumCustom(false);
			//addDigitalCopyNumCustom(true);
		}
		if(getExperimentInfo("openarrayinstrument") === "QS3D"){
			 var digRefassayObj = Ext.get('referenceassay').dom;
			 var digAssaypartoption = digRefassayObj.options[digRefassayObj.selectedIndex].value;
			 
			 if(digAssaypartoption === 'TaqMan Copy Number Reference Assay RNAse P'){
				Ext.get('digitalreferenceassay').dom.value = "TaqMan Copy Number Reference Assay RNAse P";
			 }else if(digAssaypartoption === 'TaqMan Copy Number Reference Assay TERT'){
				Ext.get('digitalreferenceassay').dom.value = "TaqMan Copy Number Reference Assay TERT";
			 }
		     addDigitalCopyNumCustom(false);
			 //addDigitalCopyNumCustom(true);
		    }else{
				//addCopyMTO();
				addCopyNum();
				addCopyNumCustomPlus();
				addCopyNumCustom();
			}
    } else if (getExperimentInfo("type") == "Mutation Detection") {
		$('#sybrsec').hide();
		var anyinstrument = $( "#anyinstrument" ).hasClass( "tbuttonselected" );
		var techboth = $( "#techboth" ).hasClass( "tbuttonselected" );
		if(anyinstrument && techboth){
			addDigitalGenoTyping(false);
			//addDigitalGenoTyping(true);
		}
        Ext.get('emessage').addCls('hidden');
		if(getExperimentInfo("openarrayinstrument") === "QS3D"){
			addDigitalGenoTyping(false);
			//addDigitalGenoTyping(true);
		}else{
			//addCopyMTO();
			addMuteDetect();
			addMuteDetectEGFR();
		}
    } else if (getExperimentInfo('type') == "Gene Expression") {
		var isQS3 = $( "#QS3" ).hasClass( "tbuttonselected" );
		var isQS5 = $( "#QS5" ).hasClass( "tbuttonselected" );
		if(getExperimentInfo("openarrayinstrument") === "QS3D"){		
			Ext.get('digitalreferenceassay').dom.value = "TaqMan Gene Expression Assays";
	    	//digRefassayObj.options[digRefassayObj.selectedIndex].value = "TaqMan Gene Expression Assays";
			addCustomDigitalPCRMTO(false);
			addCustomDigitalPCRMTO(true);
		} /*else if ( isQS3 || isQS5){
			addTAP();
			$('#sybrsec').hide();
			$('#checkboxshowsyberinfo').prop('checked',false);
		}*/else{
			$('#sybrsec').show();
			var anyinstrument = $( "#anyinstrument" ).hasClass( "tbuttonselected" );
			var techboth = $( "#techboth" ).hasClass( "tbuttonselected" );
			if(anyinstrument && techboth){
				//addDigitalGenoTyping(false);
				addCustomDigitalPCRMTO(false);
				addCustomDigitalPCRMTO(true);
			}			
			addTAC();
			addInventoried();
			addMTO();
			addCustom();
			addOTAPC();
			addOTAPI();
			addCustomPlus();
			if( (getExperimentInfo('tubeSel') != 'TAPFast') && (getExperimentInfo('tubeSel') != 'TAPStandard')){
				var exTubeSel = getExperimentInfo('tubeSel');
				updateExperimentInfo("tubeSel", "TAPFast");
			addTAP();
				updateExperimentInfo("tubeSel", exTubeSel);
				addTAP();
			}else{
				addTAP();
			}
			if(Ext.get('checkboxshowsyberinfo').dom.checked == true){
				sybr = getSYBR();
				//osybr = getOSYBR();
				//osybrf = getOSYBRF();
			}
			if (Ext.get('fixedcontfilter').dom.checked) {
				addTQACF();
				//addOTQAPF();
				addTAPF();
				addOAMIP();
				addHSCP();
				addHCP();
				addHIP();
				addHKP();
				addHSTP();
				// osybrf = getOSYBRF();
			}
		}
    } else if (getExperimentInfo('type') == "miRNA") {
		$('#sybrsec').hide();
		var anyinstrument = $( "#anyinstrument" ).hasClass( "tbuttonselected" );
		var techboth = $( "#techboth" ).hasClass( "tbuttonselected" );
		if(anyinstrument && techboth){
			addDigitalMiRNA(false);
			addDigitalMiRNA(true);
		}
        Ext.get('emessage').addCls('hidden');
		if(getExperimentInfo("openarrayinstrument") === "QS3D"){
			 addDigitalMiRNA(false);
			 addDigitalMiRNA(true);
		}else{
			if (Ext.get('fixedcontfilter').dom.checked) { 
				addMITAQCF();
				addOMIPF();
			}
			addcustMRNA();
			addInventoried();
			addMTO();
			addCustom();
            addAdvanced();
		}
        /*
        //Commented on Dec 3rd - 2013
        Ext.get('emessage').addCls('hidden');
        addcustMRNA();
        addInventoried();
        addMTO();
        addCustom();
        if (Ext.get('fixedcontfilter').dom.checked) {
            addOMIPF();
            addMITAQCF();
        }*/
    } else {		
		$('#sybrsec').hide();
		var anyinstrument = $( "#anyinstrument" ).hasClass( "tbuttonselected" );
		var techboth = $( "#techboth" ).hasClass( "tbuttonselected" );
		if(anyinstrument && techboth){
			addDigitalGenoTyping(false);
		}
        Ext.get('emessage').addCls('hidden');         
        if(getExperimentInfo('openarrayinstrument') == 'QS3D'){
        	var digRefassayObj = Ext.get('digitalreferenceassay').dom;
	    	var digAssaypartoption = digRefassayObj.options[digRefassayObj.selectedIndex].value;
	    	//alert(digAssaypartoption);
	    	if(digAssaypartoption === 'TaqMan Gene Expression Assays'){
		        addCustomDigitalPCRMTO();
		    }
		    if(digAssaypartoption === 'TaqMan Copy Number Reference Assay RNAse P' || 
		    	digAssaypartoption === 'TaqMan Copy Number Reference Assay TERT'){
		        addDigitalCopyNumCustom();
		    }
	     }else{
	    	 addODIG();
	     }
    }
    updateWarningMessage();
    updateSummaryTable();
    displayList();
}

/*
	- Added by SS on Dec-04th-2013.
	- To display the warning message in productconfig tab.
	- See Example in the file - mitaqc.js - warningEMessageArray value is pushed.
*/
function updateWarningMessage(){
	if(warningEMessageArray.length != 0 ){
		Ext.get('emessage').removeCls('hidden');
		updateContMessage();
	}
}
function updateSummaryTable() {
    tubeCustomRec = null;
    cardCustomRec = null;
    cardFixedRec = null;
    plateCustomRec = null;
    plateFixedRec = null;
    openArrayCustomRec = null;
    openArrayFixedRec = null;
	QS3DChips = null;
	QS3DChipsFixed = null;
    var itemCalcCount = 0;
	outputListTypes.splice(0, outputListTypes.length); //reset array
	
    var items = {
        A: false,
        B: false,
        C: false,
        D: false,
        E: false,
        F: false,
        G: false,
		H: false,
		I: false
    };
    if (sortedBy == 1) {
        outputList.sort('totalcost', 'ASC');
    } else {
        outputList.sort('noofhours', 'ASC');
    }
	/*outputList.each(function (e) {
		console.log(e.get('type'));
	});*/
    outputList.each(function (e) {
		//console.log(e.get('title'));
		//console.log(e.get('type'));
        if (e.get('type') == 'tube' && !items.A) {
        	if(getExperimentInfo('openarrayinstrument') == 'QS3D'){
				openArrayCustomRec = e;
				items.I = true;
				++itemCalcCount;
        	}else{
        		tubeCustomRec = e;
    	        items.A = true;
        	    ++itemCalcCount;
        	}
        } else if (e.get('type') == 'card-custom' && !items.B) {
            cardCustomRec = e;
            items.B = true;
            ++itemCalcCount;
        } else if (e.get('type') == 'card-fixed' && !items.G) {
            cardFixedRec = e;
            items.G = true;
            ++itemCalcCount;
        } else if (e.get('type') == 'plate-custom' && !items.C) {
            plateCustomRec = e;
            items.C = true;
            ++itemCalcCount;
        } else if (e.get('type') == 'plate-fixed' && !items.D) {
            plateFixedRec = e;
            items.D = true;
            ++itemCalcCount;
        } else if (e.get('type') == 'openarray-custom' && !items.E) {
            openArrayCustomRec = e;
            items.E = true;
            ++itemCalcCount;
        } else if (e.get('type') == 'openarray-fixed' && !items.F) {
            openArrayFixedRec = e;
            items.F = true;
            ++itemCalcCount;
        } else if (e.get('type') == 'chips' && !items.H) {
			QS3DChips = e;
			items.H = true;
			++itemCalcCount;
		}
		//console.log("itemCalcCount : " +itemCalcCount);
        if (itemCalcCount == 8) {
            return false;
        }
		
	
    });
	
	queryInstrument = getExperimentInfo('openarrayinstrument');
	queryInstrument = queryInstrument ? queryInstrument : defaultInstruemntID;
	insDetail 		= listOfInstrument.findRecord('InstrumentID', queryInstrument);
	insThroughput 	= insDetail.get('Throughput');
	//console.log("currMode: " + currMode + ", insThroughput: "+ insThroughput);
	
    var count = 0;
    if (tubeCustomRec) {	
        Ext.get('summ_cust_tubes').update("<a href='#' onclick='showProductList(&quot;tube&quot;, false, true); return false;'>" + convertCurrency(tubeCustomRec.get('totalcost'), region + "-" + currency) + "</a>");
        if (getExperimentInfo("type") == "Gene Expression") {
		   var graphLabel = 'Tubes';
		   var arrayRec = tubeCustomRec;
           //if (currMode == 'All') {
				if (insThroughput == "All") {
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "High") {
					typeSortArray = Array("openarray","card","tube","plate");
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "Medium") {
					typeSortArray = Array("card","tube","plate");	
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "Low") {
					typeSortArray = Array("tube","plate");
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "OA") {
				} else {
					 addSummaryChartData(arrayRec, count++, graphLabel);
				}
			//}else{
			//	addSummaryChartData(arrayRec, count++, graphLabel);
			//}
        }
    } else {
        Ext.get('summ_cust_tubes').update('N/A');
    }
    if (plateCustomRec) {
        Ext.get('summ_cust_plates').update("<a href='#' onclick='showProductList(&quot;plate-custom&quot;, false, true); return false;'>" + convertCurrency(plateCustomRec.get('totalcost'), region + "-" + currency) + "</a>");
        if (getExperimentInfo("type") == "Gene Expression") {
            //addSummaryChartData(plateCustomRec, count++, 'Array Plates');			
			var graphLabel = 'Array Plates';
			var arrayRec = plateCustomRec;
			//if (currMode == 'All') {
				if (insThroughput == "All") {
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "High") {					
					typeSortArray = Array("openarray","card","tube","plate");
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "Medium") {
					typeSortArray = Array("card","tube","plate");	
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "Low") {
					typeSortArray = Array("tube","plate");
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "OA") {
				} else {
					 addSummaryChartData(arrayRec, count++, graphLabel);
				}
			//}else{
			//	addSummaryChartData(arrayRec, count++, graphLabel);
			//}
        }
    } else {
        Ext.get('summ_cust_plates').update('N/A');
    }
    if (plateFixedRec) {
        Ext.get('summ_fixed_plates').update("<a href='#' onclick='showProductList(&quot;plate-fixed&quot;, false, true); return false;'>" + convertCurrency(plateFixedRec.get('totalcost'), region + "-" + currency) + "</a>");
        if (getExperimentInfo("type") == "Gene Expression") {
            //addSummaryChartData(plateFixedRec, count++, 'Array Plates(Fixed)');
			var graphLabel = 'Array Plates(Fixed)';
			var arrayRec = plateFixedRec;
			//if (currMode == 'All') {
				if (insThroughput == "All") {
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "High") {					
					typeSortArray = Array("openarray","card","tube","plate");
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "Medium") {										
					typeSortArray = Array("card","tube","plate");	
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "Low") {
					typeSortArray = Array("tube","plate");
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "OA") {							
				} else {
					 addSummaryChartData(arrayRec, count++, graphLabel);
				}
			//}else{
			//	addSummaryChartData(arrayRec, count++, graphLabel);
			//}
        }
    } else {
        Ext.get('summ_fixed_plates').update('N/A');
    }
    if (cardCustomRec) {
        Ext.get('summ_cust_cards').update("<a href='#' onclick='showProductList(&quot;card-custom&quot;, false, true); return false;'>" + convertCurrency(cardCustomRec.get('totalcost'), region + "-" + currency) + "</a>");
        if (getExperimentInfo("type") == "Gene Expression") {
           // addSummaryChartData(cardCustomRec, count++, 'Array Cards');
			var graphLabel = 'Array Cards';
			var arrayRec = cardCustomRec;
			//if (currMode == 'All') {
				if (insThroughput == "All") {
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "High") {					
					typeSortArray = Array("openarray","card","tube","plate");
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "Medium") {										
					typeSortArray = Array("card","tube","plate");	
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "Low") {								
				} else if (insThroughput == "OA") {
				} else {
					 addSummaryChartData(arrayRec, count++, graphLabel);
				}
			//}else{
			//	addSummaryChartData(arrayRec, count++, graphLabel);
			//}
        }
    } else {
        Ext.get('summ_cust_cards').update('N/A');
    }
    if (cardFixedRec) {
        Ext.get('summ_fixed_cards').update("<a href='#' onclick='showProductList(&quot;card-fixed&quot;, false, true); return false;'>" + convertCurrency(cardFixedRec.get('totalcost'), region + "-" + currency) + "</a>");
        if (getExperimentInfo("type") == "Gene Expression") {
            //addSummaryChartData(cardFixedRec, count++, 'Array Cards(Fixed)');
			var graphLabel = 'Array Cards(Fixed)';
			var arrayRec = cardFixedRec;
			//if (currMode == 'All') {
				if (insThroughput == "All") {
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "High") {					
					typeSortArray = Array("openarray","card","tube","plate");
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "Medium") {										
					typeSortArray = Array("card","tube","plate");	
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "Low") {
				} else if (insThroughput == "OA") {
				} else {
					 addSummaryChartData(arrayRec, count++, graphLabel);
				}
			//}else{
			//	addSummaryChartData(arrayRec, count++, graphLabel);
			//}
			
			
        }
    } else {
        Ext.get('summ_fixed_cards').update('N/A');
    }
    if (openArrayCustomRec) {
        Ext.get('summ_cust_openarray').update("<a href='#' onclick='showProductList(&quot;openarray-custom&quot;, false, true); return false;'>" + convertCurrency(openArrayCustomRec.get('totalcost'), region + "-" + currency) + "</a>");
        if (getExperimentInfo("type") == "Gene Expression") {
            //addSummaryChartData(openArrayCustomRec, count++, 'Open Array');
			var graphLabel = 'Open Array';
			var arrayRec = openArrayCustomRec;
			//if (currMode == 'All') {
				if (insThroughput == "All") {
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "High") {
					addSummaryChartData(arrayRec, count++, graphLabel);	
				} else if (insThroughput == "Medium") {
				} else if (insThroughput == "Low") {
				} else if (insThroughput == "OA" || insThroughput == "High") {
					typeSortArray = Array("openarray");	
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else {
					 addSummaryChartData(arrayRec, count++, graphLabel);
				}
			//}else{
			//	addSummaryChartData(arrayRec, count++, graphLabel);
			//}
        }
    } else {
        Ext.get('summ_cust_openarray').update('N/A');
    }
	
    if (openArrayFixedRec) {
        Ext.get('summ_fixed_openarray').update("<a href='#' onclick='showProductList(&quot;openarray-fixed&quot;, false, true); return false;'>" + convertCurrency(openArrayFixedRec.get('totalcost'), region + "-" + currency) + "</a>");
        if (getExperimentInfo("type") == "Gene Expression") {
            //addSummaryChartData(openArrayFixedRec, count++, 'Open Array(fixed)');
			var graphLabel = 'Open Array(fixed)';
			var arrayRec = openArrayFixedRec;
			//if (currMode == 'All') {
				if (insThroughput == "All") {
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "High") {
					addSummaryChartData(arrayRec, count++, graphLabel);	
				} else if (insThroughput == "Medium") {
				} else if (insThroughput == "Low") {						
				} else if (insThroughput == "OA" || insThroughput == "High") {
					typeSortArray = Array("openarray");
					addSummaryChartData(arrayRec, count++, graphLabel);	
				} else {
					 addSummaryChartData(arrayRec, count++, graphLabel);
				}
			//}else{
			//	addSummaryChartData(arrayRec, count++, graphLabel);
			//}
        }
    } else {
        Ext.get('summ_fixed_openarray').update('N/A');
    }
	if (QS3DChips) {
        Ext.get('summ_cust_chips').update("<a href='#' onclick='showProductList(&quot;chips&quot;, false, true); return false;'>" + convertCurrency(QS3DChips.get('totalcost'), region + "-" + currency) + "</a>");
        if (getExperimentInfo("type") == "Gene Expression") {
            //addSummaryChartData(openArrayCustomRec, count++, 'Open Array');
			var graphLabel = 'Chips';
			var arrayRec = QS3DChips;
			//if (currMode == 'All') {
				if (insThroughput == "All") {
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else if (insThroughput == "High") {
					addSummaryChartData(arrayRec, count++, graphLabel);	
				} else if (insThroughput == "Medium") {
				} else if (insThroughput == "Low") {
				} else if (insThroughput == "OA" || insThroughput == "High") {
					typeSortArray = Array("openarray");	
					addSummaryChartData(arrayRec, count++, graphLabel);
				} else {
					 addSummaryChartData(arrayRec, count++, graphLabel);
				}
			//}else{
			//	addSummaryChartData(arrayRec, count++, graphLabel);
			//}
        }
    } else {
        Ext.get('summ_cust_chips').update('N/A');
    }
	if(QS3DChipsFixed){
	} else {
		Ext.get('summ_fixed_chips').update('N/A');
	}
	
	if (insThroughput == "All") {		
	} else if (insThroughput == "High") {
		//High openarray,card,plate,tube
		typeSortArray = Array("openarray","card","tube","plate");
	} else if (insThroughput == "Medium") {
		//Medium plate,tube,card		
		typeSortArray = Array("card","tube","plate");
		Ext.get('summ_cust_openarray').update('N/A');
		Ext.get('summ_fixed_openarray').update('N/A');
		Ext.get('summ_cust_chips').update('N/A');
		Ext.get('summ_fixed_chips').update('N/A');
	} else if (insThroughput == "Low") {
		//Low plate,tube		
		typeSortArray = Array("tube","plate");
		Ext.get('summ_cust_cards').update('N/A');
		Ext.get('summ_fixed_cards').update('N/A');
		Ext.get('summ_cust_openarray').update('N/A');
		Ext.get('summ_fixed_openarray').update('N/A');
		Ext.get('summ_cust_chips').update('N/A');
		Ext.get('summ_fixed_chips').update('N/A');		
	} else if (insThroughput == "OA") {
		//OA openarray	
		typeSortArray = Array("openarray");	
		Ext.get('summ_cust_tubes').update('N/A');
		Ext.get('summ_cust_plates').update('N/A');
		Ext.get('summ_fixed_plates').update('N/A');
		Ext.get('summ_cust_cards').update('N/A');
		Ext.get('summ_fixed_cards').update('N/A');
		Ext.get('summ_cust_chips').update('N/A');
		Ext.get('summ_fixed_chips').update('N/A');
	}
}



var queryInstrument 	= '';
var insDetail 			= '';
var insThroughput 		= '';
var typeSortArray		= Array();
var outputListTypes 	= Array();
var CostSummaryType 	= Array();
	CostSummaryType[0]	= "card-custom";
    CostSummaryType[1]	= "card-fixed";
    CostSummaryType[2]	= "openarray-custom";
    CostSummaryType[3]	= "openarray-fixed";
    CostSummaryType[4]	= "plate-custom";
    CostSummaryType[5]	= "plate-fixed";
    CostSummaryType[6]	= "tube";


function displayList() {
    if (outputList.count() > 0) {
		outputList.sort('totalcost', 'ASC');
        var lowestTimeTitle = "<a href='#' onclick=\"showDetails('" + outputList.getAt(0).get('pno') + "');return false;\" style='color:#036AC8;text-decoration: none;'>" + outputList.getAt(0).get('title') + "</a><br />" + convertCurrency(roundNumber(outputList.getAt(0).get('totalcost'), 2), region + "-" + currency);        
        outputList.sort('noofhours', 'ASC');
		var lowestCostTitle = "<a href='#' onclick=\"showDetails('" + outputList.getAt(0).get('pno') + "');return false;\" style='color:#036AC8;text-decoration: none;'>" + outputList.getAt(0).get('title') + "</a><br />" + convertCurrency(roundNumber(outputList.getAt(0).get('totalcost'), 2), region + "-" + currency);
        Ext.get('opt1').update(lowestCostTitle);
        Ext.get('opt2').update(lowestTimeTitle);
    }
	
	if (sortedBy == 1) {
        outputList.sort('totalcost', 'ASC');
    } else {
        outputList.sort('noofhours', 'ASC');
    }
    displayByInstruemnt();
	
}

function createtypeSortArray(){
	 if (currMode == 'All') {
        var queryInstrument = getExperimentInfo('openarrayinstrument');
		queryInstrument = queryInstrument ? queryInstrument : defaultInstruemntID;
		var insDetail = listOfInstrument.findRecord('InstrumentID', queryInstrument);
		var insThroughput = insDetail.get('Throughput');
		
		if (insThroughput == "All") {
			typeSortArray = Array();
		} else if (insThroughput == "High") {
			typeSortArray = Array("openarray","card","tube","plate");
		} else if (insThroughput == "Medium") {			
			typeSortArray = Array("card","tube","plate");
		} else if (insThroughput == "Low"){
			typeSortArray = Array("tube","plate");
		} else if (insThroughput == "OA") {
			typeSortArray = Array("openarray");
		} else {
			typeSortArray = Array();
		}
	 }
}

function displayByInstruemnt(){
	//console.log('-----------------displayByInstruemnt-------------------')
	listHtml = "";
    // filtering based on currMode with in outputlist
    //if (currMode == 'All') {
		
		queryInstrument = getExperimentInfo('openarrayinstrument');
		queryInstrument = queryInstrument ? queryInstrument : defaultInstruemntID;
		insDetail 		= listOfInstrument.findRecord('InstrumentID', queryInstrument);
		insThroughput 	= insDetail.get('Throughput');
		
		if (insThroughput == "All") {			
			displaySortedList();
			if (getExperimentInfo("type") != "Gene Expression") {
				loadChartData();
			}
		} else if (insThroughput == "High") {
			//High
			typeSortArray = Array("openarray","card","tube","plate","chips");
			showProductListByTypeList(typeSortArray, false, true);
			//showProductList('openarray', true, true);
			//showProductList('card', false, false);
			//showProductList('tube', false, false);
			//showProductList('plate', false, false);			
			if (getExperimentInfo("type") != "Gene Expression") {
				loadChartDataByInstruement(typeSortArray)
			}
		} else if (insThroughput == "Medium") {
			//Medium
			typeSortArray = Array("card","tube","plate");
			showProductListByTypeList(typeSortArray, false, true);
			//showProductList('card', true, true);
			//showProductList('tube', false, false);
			//showProductList('plate', false, false);
			if (getExperimentInfo("type") != "Gene Expression") {
				loadChartDataByInstruement(typeSortArray)
			}
		} else if (insThroughput == "Low") {
			//Low
			typeSortArray = Array("tube","plate");
			showProductListByTypeList(typeSortArray, false, true);
			//showProductList('tube', true, true);
			//showProductList('plate', false, false);
			//displaySYBR('n');
			if (getExperimentInfo("type") != "Gene Expression") {
				loadChartDataByInstruement(typeSortArray)
			}
		} else if (insThroughput == "OA") {
			//OA
			//alert("insThroughput<OA: " + insThroughput)
			typeSortArray = Array("openarray");
			showProductListByTypeList(typeSortArray, false, true);
			//showProductList('openarray', false, true);
			if (getExperimentInfo("type") != "Gene Expression") {
				loadChartDataByInstruement(typeSortArray)
			}
		} else {
			//alert("insThroughput<Blank: " + insThroughput)
			displaySortedList();
			if (getExperimentInfo("type") != "Gene Expression") {
				loadChartData();
			}
		}
    /*} else if (currMode == 'High') {
        showProductList('openarray', true, false);
        showProductList('card', false, false);
		if (getExperimentInfo("type") != "Gene Expression") {
			loadChartData();
		}
    } else if (currMode == 'Low') {
        showProductList('tube', true, false);
        showProductList('plate', false, false);
       // displaySYBR('n');
		if (getExperimentInfo("type") != "Gene Expression") {
			loadChartData();
		}
    }*/
    // for gene expression we are loading chart data based on summary table
    // entries to minimize no of items in chart view.
    /*if (getExperimentInfo("type") != "Gene Expression") {
        loadChartData();
    }*/
	/*
    outputListTypes = uniqueArray(outputListTypes);    
    if (outputListTypes.length > 0) for (x = 0; x < CostSummaryType.length; x++) {
            //alert(CostSummaryType[x] + " - " + x)
            if (isValueInArray(CostSummaryType[x], outputListTypes)) {
                //alert(CostSummaryType[x] + " - " + x)
            } else {
                if(CostSummaryType[i] == "card-custom")
					Ext.get('summ_cust_cards').update('N/A');
				else if(CostSummaryType[i] == "card-fixed")
					Ext.get('summ_fixed_cards').update('N/A');					
				else if(CostSummaryType[i] == "openarray-custom")
					Ext.get('summ_cust_cards').update('N/A');
				else if(CostSummaryType[i] == "openarray-fixed")
					Ext.get('summ_fixed_cards').update('N/A');
				else if(CostSummaryType[i] == "plate-custom")
					Ext.get('summ_cust_plates').update('N/A');
				else if(CostSummaryType[i] == "plate-fixed")
					Ext.get('summ_fixed_plates').update('N/A');
				else if(CostSummaryType[i] == "tube")
					Ext.get('summ_cust_tubes').update('N/A');
            }
    }
	*/
}





function showProductListByTypeList(typelist, contd, summFilter) {	
	 if (summFilter) {
        listHtml = "";
    }	
   // alert(dump(typelist))
	composeOutPutHtmlByTypeList(typelist, contd);
}
function composeOutPutHtmlByTypeList(typelist, contn) {	
    outputList.each(function (e) {
		type = e.get('type'); 
		types = type.split("-");
		
		if (isValueInArray(types[0], typeSortArray) && displayListBasedOnConsumables(types[0])) {
			//console.log(' PNO ' + e.get('pno'));
			composeOutPutHtmls(e);
		} 
    });
	//console.log("-------------------totalcost-------------------------");
	var newlist = outputList;
	var setcostandworkflow = false;
	
	newlist.sort('totalcost', 'ASC');
	setcostandworkflow = false;
	newlist.each(function (e) {
		if(!setcostandworkflow){
			type = e.get('type');
			types = type.split("-");			
			if (isValueInArray(types[0], typeSortArray)) {
				var lowestCostTitle = "<a href='#' onclick=\"showDetails('" + e.get('pno') + "');return false;\" style='color:#036AC8;text-decoration: none;'>" + e.get('title') + "</a><br />" + convertCurrency(roundNumber(e.get('totalcost'), 2), region + "-" + currency);
				Ext.get('opt1').update(lowestCostTitle);
				//console.log(e.get('title'));
				setcostandworkflow = true;
			}
		}
    });
	//console.log("-------------------noofhours-------------------------");
	newlist.sort('noofhours', 'ASC');
	setcostandworkflow = false;
	newlist.each(function (e) {
		if(!setcostandworkflow){
			type = e.get('type');
			types = type.split("-");			
			if (isValueInArray(types[0], typeSortArray)) {
				var lowestTimeTitle = "<a href='#' onclick=\"showDetails('" + e.get('pno') + "');return false;\" style='color:#036AC8;text-decoration: none;'>" + e.get('title') + "</a><br />" + convertCurrency(roundNumber(e.get('totalcost'), 2), region + "-" + currency);
				Ext.get('opt2').update(lowestTimeTitle);
				//console.log(e.get('title'));
				setcostandworkflow = true;
			}
		}			 
    });
	
	//console.log("----------------------end----------------------");
	if (getExperimentInfo("type") == "Gene Expression") {
		if(Ext.get('checkboxshowsyberinfo').dom.checked == true){
			//displaySYBR('o');
			//displaySYBR('f');
			displaySYBR('n');
		}
    }
    if (!contn) {	
		
        if (listHtml == "") {
            listHtml += "<div style='text-align:center;margin-top:125px;width:695px;font-size: 15px;'>There are no products that match the specified criteria.You might want to include fixed panels by selecting show fixed content check box.</div>";
        }
        Ext.fly('tab2cont').dom.innerHTML = listHtml;
    }
}

function composeOutPutHtmls(e) {

		var isCSPCalc = false;
		if(getExperimentInfo("isCustomPlatingCalc")){
			isCSPCalc = true;
		}
		//console.log('e.get(\'type\'): ' + e.get('type'));
		var anyinstrument = $( "#anyinstrument" ).hasClass( "tbuttonselected" );
		var techboth = $( "#techboth" ).hasClass( "tbuttonselected" );
		if(anyinstrument && techboth){
			Ext.get('summ_cust_chips').update("<a href='#' onclick='showProductList(&quot;chips&quot;, false, true); return false;'>" + convertCurrency(e.get('totalcost'), region + "-" + currency) + "</a>");
		}
		
		listHtml += "<div class='box clearfix'>";
		if( e.get('imageType').length == 0 ){
			listHtml += "<div class='leftcont'><img width='100px' height='100px' src='images/" + e.get('type') + ".jpg'/></div>";
		}else{
			listHtml += "<div class='leftcont'><img width='100px' height='100px' src='images/" + e.get('imageType') + ".jpg'/></div>";
		}
		/*if(e.get('format').indexOf('Chips') == -1){
			listHtml += "<div class='leftcont'><img src='images/" + e.get('type') + ".jpg'/></div>";
		}else{
			listHtml += "<div class='leftcont'><img width='100px' height='100px'   src='images/chip.jpg'/></div>";
		}*/
		listHtml += "<div class='middlecont'>";
		listHtml += "<div><span class='title'>" + e.get('title') + "</span>&nbsp;&nbsp;</div>";
		listHtml += "<span style='color: #036AC8;'><a target='_blank' href='" + e.get('producturl') + "'>Product Page</a></span>";
		listHtml += "<div class='clearfix'><span style='float:left;display:inline;width:150px;' class='lablemedium'>Format:</span><span style='width:230px;display:inline;float:left;' class='right lablemedium'>" + e.get('format') + "</span></div>";
		//listHtml += "<div class='clearfix'><span style='float:left;display:inline;width:150px;' class='lablemedium'>Number of units:</span><span style='width:230px;display:inline;float:left;' class='right lablemedium'>"
		//+ e.get('noofunits') + "</span></div>";
		
		if(Development){
			//listHtml += "<div class='clearfix left' style='width:150px;border:1px solid red;margin-top:7px;'><span style='float:left;display:inline;width:70px;color:#000;' class='lablemedium'>Number of units:</span><span style='width:50px;display:inline;float:left;color:#000;' class='right lablemedium'>" + e.get('noofunits') + " = "+ e.get('min') + " = " + e.get('ismin') + "</span></div>";
			//listHtml += "<div class='clearfix left' style='width:150px;margin-top:7px;'><span style='float:left;display:inline;width:70px;color:#000;' class='lablemedium'>Number of units:</span><span style='width:50px;display:inline;float:left;color:#000;' class='right lablemedium'>" + e.get('noofunits') + "</span></div>";
			listHtml += "<div class='clearfix left' style='width:150px;margin-top:7px;'><span style='float:left;display:inline;color:#000;' class='lablemedium'>Number of units: "+e.get('noofunits') +"</span></div>";
			console.log(e.get('noofunits'));
		}else{
			//listHtml += "<div class='clearfix left' style='width:150px;margin-top:7px;'><span style='float:left;display:inline;width:70px;color:#000;' class='lablemedium'>Number of units:</span><span style='width:50px;display:inline;float:left;color:#000;' class='right lablemedium'>" + e.get('noofunits') + "</span></div>";
			listHtml += "<div class='clearfix left' style='width:150px;margin-top:7px;'><span style='float:left;display:inline;color:#000;' class='lablemedium'  >Number of units: "+e.get('noofunits') +"</span></div>";
			//id = '"+e.get('title')+"' onmouseover = 'tooltip(this, &quot;"+e.get('noofunits')+"&quot;, &quot;"+ e.get('min')+"&quot;);'
			
		}
		
		
			
		if (e.get('min')) {
			if(e.get('ismin') == 0)
				listHtml += "<div style='margin-top:5px; margin-left:150px;'><span class='lablebig'>" + roundNumber(e.get('noofhours'), 2) + "&nbsp;hour</span>&nbsp;workflow</div>";
			else
				listHtml += "<div style='margin-top:5px;'><span class='lablebig'>" + roundNumber(e.get('noofhours'), 2) + "&nbsp;hour</span>&nbsp;workflow</div>";
		}else{
			listHtml += "<div style='margin-top:5px;'><span class='lablebig'>" + roundNumber(e.get('noofhours'), 2) + "&nbsp;hour</span>&nbsp;workflow</div>";
		}
		
		listHtml += "<div class='clear'></div>";
		
		var strunit =  GetUnitsPerCradsPlatesArray(e.get('partnumber'), 'unit', true);
		var strQty =  GetUnitsPerCradsPlatesArray(e.get('partnumber'), 'minQty', false);
		var unitHtml = '';
		listHtml += "<div style='width:157px;margin-top:7px;' class='clearfix left'><span class='lablemedium' style='float:left;display:inline;color:#000;'>";
		
		if(strunit != 'NO') {
			listHtml += "&#8226; 1 Unit is "+strunit+".<BR>";
		}else{
			var strtemp = e.get('type').split('-')[0]; console.log(strtemp);
			if( getExperimentInfo("isCustomPlatingCalc") && getExperimentInfo("cpsConsumableType") == "openarray" ){
				listHtml += "&#8226; 1 Unit is 10 "+strtemp+".<BR>";
			} else {
				listHtml += "&#8226; 1 Unit is 1 "+strtemp+".<BR>";
			}
		}
		
		//alert( e.get('title')+ ' = = '+strQty);
		if(e.get('ismin') == 0){ 
			if (strQty != 'NO' ) {
				listHtml += "&#8226; Actual quantity is : "+e.get('reqnoofunits')+".";
			}else if(strQty === 'NO' && e.get('min') !== 0){
				listHtml += "&#8226; Actual quantity is : "+e.get('reqnoofunits')+".";
			}
		}
		
		var rowotherTiltle = e.get('format');
		var buttonName ='';
		var isDrugMetabolism = false;
		var tType = e.get('type'); 
		if(rowotherTiltle.indexOf('Fixed Panels') == -1){
			isDrugMetabolism = false;
			if ( ((rowotherTiltle.indexOf('Card') != -1) || (rowotherTiltle.indexOf('Plate') != -1) || (e.get('type') == 'tube')) && (getExperimentInfo("type") != "Mutation Detection") &&  (rowotherTiltle.indexOf('OpenArray') == -1) && (tType.indexOf('fixed') == -1) ) {
				var cardPlate = "";
				var fastStandard = "";
				if ( rowotherTiltle.indexOf('Card') != -1 ){
					cardPlate = "Card";
					buttonName = "View Other Formats";
					//listHtml += '<div id="prodConfigViewFormatCard"></div>';
				} else if ( rowotherTiltle.indexOf('Plate') != -1 ){
					cardPlate = "Plate";
					buttonName = "View Other Formats";
					if( e.get('title').indexOf('Fast') != -1 ){
						fastStandard = "Fast";
					}else{
						fastStandard = "Standard";
					}
					//listHtml += '<div id="prodConfigViewFormatPlate"></div>';
				} else if ( rowotherTiltle.indexOf('DME') != -1 ){
					isDrugMetabolism = true;
				} else {
					buttonName = "View other sizes and product flavours";
				}
				if( !isCSPCalc && !isDrugMetabolism) {
					listHtml += '<span class="viewParnt viewOthrFrmt" id=""><div id="prodConfigViewFormat'+cardPlate+'" class="prodConfigViewFormat"></div><button class="viewDet viewOthrFrmtBut" value="viewDetailCont_prodConfigViewFormat'+cardPlate+'_'+e.get('pno')+'_'+fastStandard+'" onclick="ViewDetails(\''+e.get('format')+'\', this, \''+e.get('type')+'\'); return false;">'+buttonName+'</button></span>&nbsp;';
				}
			}
		}
		listHtml += "</span></div>";
		// if (e.get('noofunits') < e.get('min')) {
		if (e.get('min')) {
			//var minSpan = e.get('ismin') == 0 ? "<span style='width:20px;display:inline;float:left;color:white;background:red;' class='right lablemedium'>": "<span style='width:20px;display:inline;float:left;color:#000;' class='right lablemedium'>";
			var minSpan = "<span style='width:20px;display:inline;float:left;color:white;background:red;' class='right lablemedium'>";
			//listHtml += "<div class='clearfix left' style='width:160px;margin-top:7px;'><img src='images/alert.png' class='left' style='padding-right:5px;'><span style='float:left;display:inline;width:100px;color:#000;' class='lablemedium left'>Minimum Purchase Qty.:</span>" + minSpan + +e.get('min') + "</span></div> <div class='clear'></div>";
			
			if(e.get('ismin') == 0){
				listHtml += "<div style='margin-top:5px;'><img src='images/alert-yellow.png' class='left' style='padding-right:5px;'><span style='float:left;display:inline;width:200px;color:#000;' class='lablemedium left'>Minimum purchase quantity used because required # of units is less than min. purchase qty</span></div>";	
				
				//listHtml += "<div class='clearfix left' style='float:left; width:230px;margin-top:7px;'><img src='images/alert-yellow.png' class='left' style='padding-right:5px;'><span style='float:left;display:inline;width:200px;color:#000;' class='lablemedium left'>Minimum purchase quantity used because required # of units is less than min. purchase qty</span></div> <div class='clear'></div>";
				 
			}
		}
	   // }
		
		
		//listHtml += "<div style='margin-top:5px;'><span class='lablebig'>" + roundNumber(e.get('noofhours'), 2) + "&nbsp;hour</span>&nbsp;workflow</div>";
		listHtml += "</div>";
		listHtml += "<div class='rightcont'>";
		listHtml += "<div><span class='lablebig'>" + convertCurrency(roundNumber(e.get('totalcost'), 2), region + "-" + currency) + "</span>&nbsp;<span class='lablemedium'>" + "</span></div>";
		if( !isCSPCalc) {
			listHtml += "<div><span class='lablemedium'>Per rxn: " + convertCurrency(((e.get('totalcostperreaction'))), region + "-" + currency) + "</span></div>";
			listHtml += "<div><span class='lablemedium'>Per smpl: " + convertCurrency(((e.get('totalcostpersample'))), region + "-" + currency) + "</span></div>";
		}
		listHtml += "<div style='margin-top:15px;' class='ie7selector'>";
		if (!isGeneExpFixed(e.get('pno'))) {
			
			listHtml += "<span class='sbutton' onclick='showDetails(&quot;" + e.get('pno') + "&quot;)'>Details</span>";
		}
		
		if(Development){
			//alert("types:" + e.get('type'))
			
			listHtml += "<br /> C";
			listHtml += e.get('type');
		}
		listHtml += "</div></div>";
		listHtml += "</div>";
}



function showProductList(type, contd, summFilter) {	
    if (summFilter) {
        listHtml = "";
    }
	composeOutPutHtml(type, contd);
	updateExperimentInfo("formatFilter", type);
}

function composeOutPutHtml(type, contn) { 
	outputList.each(function (e) {
        if (e.get('type').indexOf(type) != -1) {
			//outputListTypes[(outputListTypes.length+1)] = e.get('type');			
			//console.log("->" + e.get('type').indexOf(type));
			//console.log("->" + e.get('type') + " == " + type);
            listHtml += "<div class='box clearfix'>";
			if( e.get('imageType').length == 0 ){
				listHtml += "<div class='leftcont'><img width='100px' height='100px' src='images/" + e.get('type') + ".jpg'/></div>";
			}else{
				listHtml += "<div class='leftcont'><img width='100px' height='100px' src='images/" + e.get('imageType') + ".jpg'/></div>";
			}
            listHtml += "<div class='middlecont'>";
            listHtml += "<div><span class='title'>" + e.get('title') + "</span>&nbsp;&nbsp;</div>";
			listHtml += "<span style='color: #036AC8;'><a target='_blank' href='" + e.get('producturl') + "'>Product Page</a></span>";
            listHtml += "<div class='clearfix'><span style='float:left;display:inline;width:150px;' class='lablemedium'>Format:</span><span style='width:230px;display:inline;float:left;' class='right lablemedium'>" + e.get('format') + "</span></div>";
            //listHtml += "<div class='clearfix'><span style='float:left;display:inline;width:150px;' class='lablemedium'>Number of units:</span><span style='width:230px;display:inline;float:left;' class='right lablemedium'>"
            //+ e.get('noofunits') + "</span></div>";
            
			if(Development){
				//listHtml += "<div class='clearfix left' style='width:150px;border:1px solid red;margin-top:7px;'><span style='float:left;display:inline;width:70px;color:#000;' class='lablemedium'>Number of units:</span><span style='width:50px;display:inline;float:left;color:#000;' class='right lablemedium'>" + e.get('noofunits') + " = "+ e.get('min') + " = " + e.get('ismin') + "</span></div>";
				//listHtml += "<div class='clearfix left' style='width:150px;margin-top:7px;'><span style='float:left;display:inline;width:70px;color:#000;' class='lablemedium'>Number of units:</span><span style='width:50px;display:inline;float:left;color:#000;' class='right lablemedium'>" + e.get('noofunits') + "</span></div>";
				listHtml += "<div class='clearfix left' style='width:150px;margin-top:7px;'><span style='float:left;display:inline;color:#000;' class='lablemedium'>Number of units: "+e.get('noofunits') +"</span></div>";
				console.log(e.get('noofunits'));
			}else{
				//listHtml += "<div class='clearfix left' style='width:150px;margin-top:7px;'><span style='float:left;display:inline;width:70px;color:#000;' class='lablemedium'>Number of units:</span><span style='width:50px;display:inline;float:left;color:#000;' class='right lablemedium'>" + e.get('noofunits') + "</span></div>";
				listHtml += "<div class='clearfix left' style='width:150px;margin-top:7px;'><span style='float:left;display:inline;color:#000;' class='lablemedium'>Number of units: "+e.get('noofunits') +"</span></div>";
				console.log(e.get('noofunits'));
			}
			
			
			
		   
			if (e.get('min')) {
				if(e.get('ismin') == 0)
					listHtml += "<div style='margin-top:5px; margin-left:150px;'><span class='lablebig'>" + roundNumber(e.get('noofhours'), 2) + "&nbsp;hour</span>&nbsp;workflow</div>";
				else
					listHtml += "<div style='margin-top:5px;'><span class='lablebig'>" + roundNumber(e.get('noofhours'), 2) + "&nbsp;hour</span>&nbsp;workflow</div>";
			}else{
				listHtml += "<div style='margin-top:5px;'><span class='lablebig'>" + roundNumber(e.get('noofhours'), 2) + "&nbsp;hour</span>&nbsp;workflow</div>";
			}
			
			// if (e.get('noofunits') < e.get('min')) {
				if (e.get('min')) {
					//var minSpan = e.get('ismin') == 0 ? "<span style='width:20px;display:inline;float:left;color:white;background:red;' class='right lablemedium'>": "<span style='width:20px;display:inline;float:left;color:#000;' class='right lablemedium'>";
					var minSpan = "<span style='width:20px;display:inline;float:left;color:white;background:red;' class='right lablemedium'>";
					//listHtml += "<div class='clearfix left' style='width:160px;margin-top:7px;'><img src='images/alert.png' class='left' style='padding-right:5px;'><span style='float:left;display:inline;width:100px;color:#000;' class='lablemedium left'>Minimum Purchase Qty.:</span>" + minSpan + +e.get('min') + "</span></div> <div class='clear'></div>";
					if(e.get('ismin') == 0){
						//listHtml += "<div class='clearfix left' style='width:160px;margin-top:7px;'><img src='images/alert-yellow.png' class='left' style='padding-right:5px;'><span style='float:left;display:inline;width:135px;color:#000;' class='lablemedium left'>Number of units recommended is <strong>" + e.get('min') + "</strong> purchase quantity</span></div> <div class='clear'></div>";
						  listHtml += "<div class='clearfix left' style='width:230px;margin-top:7px;'><img src='images/alert-yellow.png' class='left' style='padding-right:5px;'><span style='float:left;display:inline;width:200px;color:#000;' class='lablemedium left'>Minimum purchase quantity used because required # of units is less than min. purchase qty</span></div> <div class='clear'></div>";
					}
				}
		   // }
			listHtml += "<div class='clear'></div>";
			var rowotherTiltle = e.get('format');
			var buttonName ='';
			var isDrugMetabolism = false;
			var tType = e.get('type'); 
			if(rowotherTiltle.indexOf('Fixed Panels') == -1){
				isDrugMetabolism = false;
				if ( ((rowotherTiltle.indexOf('Card') != -1) || (rowotherTiltle.indexOf('Plate') != -1) || (e.get('type') == 'tube')) && (getExperimentInfo("type") != "Mutation Detection") &&  (rowotherTiltle.indexOf('OpenArray') == -1) && (tType.indexOf('fixed') == -1) ) {
					var cardPlate = "";
					var fastStandard = "";
					if ( rowotherTiltle.indexOf('Card') != -1 ){
						cardPlate = "Card";
						buttonName = "View Other Formats";
						//listHtml += '<div id="prodConfigViewFormatCard"></div>';
					} else if ( rowotherTiltle.indexOf('Plate') != -1 ){
						cardPlate = "Plate";
						buttonName = "View Other Formats";
						if( e.get('title').indexOf('Fast') != -1 ){
							fastStandard = "Fast";
						}else{
							fastStandard = "Standard";
						}
						//listHtml += '<div id="prodConfigViewFormatPlate"></div>';
					} else if ( rowotherTiltle.indexOf('DME') != -1 ){
						isDrugMetabolism = true;
					} else {
						buttonName = "View other sizes and product flavours";
					}
					if(!isDrugMetabolism){
					listHtml += '<span class="viewParnt viewOthrFrmt" id=""><div id="prodConfigViewFormat'+cardPlate+'" class="prodConfigViewFormat"></div><button class="viewDet viewOthrFrmtBut" value="viewDetailCont_prodConfigViewFormat'+cardPlate+'_'+e.get('pno')+'_'+fastStandard+'" onclick="ViewDetails(\''+e.get('format')+'\', this, \''+e.get('type')+'\'); return false;">'+buttonName+'</button></span>&nbsp;';
					}
				}
			}
            //listHtml += "<div style='margin-top:5px;'><span class='lablebig'>" + roundNumber(e.get('noofhours'), 2) + "&nbsp;hour</span>&nbsp;workflow</div>";
            listHtml += "</div>";
            listHtml += "<div class='rightcont'>";
            listHtml += "<div><span class='lablebig'>" + convertCurrency(roundNumber(e.get('totalcost'), 2), region + "-" + currency) + "</span>&nbsp;<span class='lablemedium'>" + "</span></div>";
            listHtml += "<div><span class='lablemedium'>Per rxn: " + convertCurrency(((e.get('totalcostperreaction'))), region + "-" + currency) + "</span></div>";
            listHtml += "<div><span class='lablemedium'>Per smpl: " + convertCurrency(((e.get('totalcostpersample'))), region + "-" + currency) + "</span></div>";
            listHtml += "<div style='margin-top:15px;' class='ie7selector'>";
            if (!isGeneExpFixed(e.get('pno'))) {
				
                listHtml += "<span class='sbutton' onclick='showDetails(&quot;" + e.get('pno') + "&quot;)'>Details</span>";
            }
			
			if(Development){
				//alert("types:" + e.get('type'))
				
            	listHtml += "<br /> C";
            	listHtml += e.get('type');
			}
            listHtml += "</div></div>";
            listHtml += "</div>";
        }
    });
	
    if (!contn) {
		if (listHtml == "") {
            listHtml += "<div style='text-align:center;margin-top:125px;width:695px;font-size: 15px;'>There are no products that match the specified criteria.You might want to include fixed panels by selecting show fixed content check box.</div>";
        }
        Ext.fly('tab2cont').dom.innerHTML = listHtml;
    }
}

function displaySortedList() {
	//console.log('-----------------displaySortedList-------------------')	
    listHtml = "";
    outputList.each(function (e) {
		//console.log(' PNO ' + e.get('pno'));
        listHtml += "<div class='box clearfix'>";
        listHtml += "<div class='leftcont'><img src='images/" + e.get('type') + ".jpg'/></div>";
        listHtml += "<div class='middlecont'>";
        listHtml += "<div><span class='title'>" + e.get('title') + "</span>&nbsp;&nbsp;</div>";
		listHtml += "<span style='color: #036AC8;'><a target='_blank' href='" + e.get('producturl') + "'>Product Page</a></span>";
        /*listHtml += "<div class='clearfix'><span style='float:left;display:inline;width:150px;' class='lablemedium'>Format:</span><span style='width:230px;display:inline;float:left;' class='right lablemedium'>"
						+ e.get('format') + "</span></div>";
				listHtml += "<div class='clearfix'><span style='float:left;display:inline;width:150px;' class='lablemedium'>Number of units:</span><span style='width:230px;display:inline;float:left;' class='right lablemedium'>"
						+ e.get('noofunits') + "</span></div>";
				if (e.get('min')) {
					var minSpan = e.get('ismin') == 0 ? "<span style='width:20px;display:inline;float:left;color:white;background:red;' class='right lablemedium'>"
							: "<span style='width:20px;display:inline;float:left;' class='right lablemedium'>";
					listHtml += "<div class='clearfix'><span style='float:left;display:inline;width:150px;' class='lablemedium'>Min of units:</span>"
							+ minSpan + +e.get('min') + "</span></div>";
				}*/
        listHtml += "<div class='clearfix'><span style='float:left;display:inline;width:150px;color:#000;' class='lablemedium'>Format:</span><span style='width:230px;display:inline;float:left;color:#000;' class='right lablemedium'>" + e.get('format') + "</span></div>";
        if(Development){
			//listHtml += "<div class='clearfix left' style='width:150px;border:1px solid red;margin-top:7px;'><span style='float:left;display:inline;width:70px;color:#000;' class='lablemedium'>Number of units:</span><span style='width:50px;display:inline;float:left;color:#000;' class='right lablemedium'>" + e.get('noofunits') + " = "+ e.get('min') + " = " + e.get('ismin') + "</span></div>";
			//listHtml += "<div class='clearfix left' style='width:150px;margin-top:7px;'><span style='float:left;display:inline;width:70px;color:#000;' class='lablemedium'>Number of units:</span><span style='width:50px;display:inline;float:left;color:#000;' class='right lablemedium'>" + e.get('noofunits') + "</span></div>";
			//listHtml += "<div class='clearfix left' style='width:150px;margin-top:7px;'><span style='float:left;display:inline;color:#000;' class='lablemedium'>Number of units: "+e.get('noofunits') +"</span></div>";
			listHtml += "<div class='clearfix left' style='width:150px;margin-top:7px;'><span style='float:left;display:inline;color:#000;' class='lablemedium'>Number of units: "+e.get('noofunits') +"</span></div>";
		}else{
			//listHtml += "<div class='clearfix left' style='width:150px;margin-top:7px;'><span style='float:left;display:inline;width:70px;color:#000;' class='lablemedium'>Number of units:</span><span style='width:50px;display:inline;float:left;color:#000;' class='right lablemedium'>" + e.get('noofunits') + "</span></div>";
			listHtml += "<div class='clearfix left' style='width:150px;margin-top:7px;'><span style='float:left;display:inline;color:#000;' class='lablemedium'>Number of units: "+e.get('noofunits') +"</span></div>";
		}
		
		
       
	    if (e.get('min')) {
			if(e.get('ismin') == 0)
				listHtml += "<div style='margin-top:5px; margin-left:150px;'><span class='lablebig'>" + roundNumber(e.get('noofhours'), 2) + "&nbsp;hour</span>&nbsp;workflow</div>";
			else
				listHtml += "<div style='margin-top:5px;'><span class='lablebig'>" + roundNumber(e.get('noofhours'), 2) + "&nbsp;hour</span>&nbsp;workflow</div>";
		}else{
			listHtml += "<div style='margin-top:5px;'><span class='lablebig'>" + roundNumber(e.get('noofhours'), 2) + "&nbsp;hour</span>&nbsp;workflow</div>";
		}
		
		
		// if (e.get('noofunits') < e.get('min')) {
            if (e.get('min')) {
                //var minSpan = e.get('ismin') == 0 ? "<span style='width:20px;display:inline;float:left;color:white;background:red;' class='right lablemedium'>": "<span style='width:20px;display:inline;float:left;color:#000;' class='right lablemedium'>";
                var minSpan = "<span style='width:20px;display:inline;float:left;color:white;background:red;' class='right lablemedium'>";
                //listHtml += "<div class='clearfix left' style='width:160px;margin-top:7px;'><img src='images/alert.png' class='left' style='padding-right:5px;'><span style='float:left;display:inline;width:100px;color:#000;' class='lablemedium left'>Minimum Purchase Qty.:</span>" + minSpan + +e.get('min') + "</span></div> <div class='clear'></div>";
                if(e.get('ismin') == 0){
					//listHtml += "<div class='clearfix left' style='width:160px;margin-top:7px;'><img src='images/alert-yellow.png' class='left' style='padding-right:5px;'><span style='float:left;display:inline;width:135px;color:#000;' class='lablemedium left'>Number of units recommended is <strong>" + e.get('min') + "</strong> purchase quantity</span></div> <div class='clear'></div>";
					  listHtml += "<div class='clearfix left' style='width:230px;margin-top:7px;'><img src='images/alert-yellow.png' class='left' style='padding-right:5px;'><span style='float:left;display:inline;width:200px;color:#000;' class='lablemedium left'>Minimum purchase quantity used because required # of units is less than min. purchase qty</span></div> <div class='clear'></div>";
				}
            }
       // }
        
        listHtml += "</div>";
        listHtml += "<div class='rightcont'>";
        listHtml += "<div><span class='lablebig'>" + convertCurrency(roundNumber(e.get('totalcost'), 2), region + "-" + currency) + "</div>";
        listHtml += "<div><span class='lablemedium'>Per rxn: " + convertCurrency(((e.get('totalcostperreaction'))), region + "-" + currency) + "</span></div>";
        listHtml += "<div><span class='lablemedium'>Per smpl: " + convertCurrency(((e.get('totalcostpersample'))), region + "-" + currency) + "</span></div>";
        listHtml += "<div style='margin-top:15px;' class='ie7selector'>";
        if (!isGeneExpFixed(e.get('pno'))) {
            listHtml += "<span class='sbutton' onclick='showDetails(&quot;" + e.get('pno') + "&quot;)'>Details</span>";
        }
        if(Development){
			listHtml += "<br /> DS";
			listHtml += e.get('type');
		}
        listHtml += "</div></div>";
        listHtml += "</div>";
    });
    /*if (getExperimentInfo("type") == "Gene Expression") {
		if(Ext.get('checkboxshowsyberinfo').dom.checked == true){
			 displaySYBR('o');
			 displaySYBR('f');
			 displaySYBR('n');
		}
    }*/
    Ext.fly('tab2cont').dom.innerHTML = listHtml;
}

function displaySYBR(type) {
	//if(!type) return false;
	$("#editInputBt").hide();
    var e = null;
    if (type == 'n') {
        e = sybr;
    } 
/*else if (type == 'o') {
        e = osybr;
    } else {
        e = osybrf;
    }  */
    listHtml += "<div class='box clearfix'>";
    listHtml += "<div class='leftcont'><img src='images/" + e.type + ".jpg'/></div>";
    listHtml += "<div class='middlecont'>";
    listHtml += "<div><span class='title'>" + e.title + "</span>&nbsp;&nbsp;</div>";
    listHtml += "<div class='clearfix'><span style='float:left;display:inline;width:150px;' class='lablemedium'>Format:</span><span style='width:230px;display:inline;float:left;' class='right lablemedium'>" + e.format + "</span></div>";
    listHtml += "<div class='clearfix'><span style='float:left;display:inline;width:150px;' class='lablemedium'>Number of units:</span><span style='width:230px;display:inline;float:left;' class='right lablemedium'>" + e.noofunits + "</span></div>";
    //listHtml += "<div style='margin-top:5px;'><span class='lablebig'>" + roundNumber(e.noofhours, 2) + "&nbsp;hour</span>&nbsp;workflow</div>";
	listHtml += "<div style='margin-top:5px; margin-left:150px;'><span class='lablebig'>" + roundNumber(e.noofhours, 2) + "&nbsp;hour</span>&nbsp;workflow</div>";
    listHtml += "</div>";
    listHtml += "<div class='rightcont'>";
	
    listHtml += "<div><span class='lablebig'>" + convertCurrency(roundNumber(e.totalcost, 2), region + "-" + currency) + "</div>";
    listHtml += "<div><span class='lablemedium'>Per rxn: " + convertCurrency(((e.totalcostperreaction)), region + "-" + currency) + "</span></div>";
    listHtml += "<div><span class='lablemedium'>Per smpl: " + convertCurrency(((e.totalcostpersample)), region + "-" + currency) + "</span></div>";
    listHtml += "<div style='margin-top:15px;' class='ie7selector'>";
	if (type == 'n') {
		listHtml += "<span class='sbutton' onclick='showSybrDetails(&quot;n"+ "&quot;)'>Details</span>";
	} else if (type == 'o') {
		listHtml += "<span class='sbutton' onclick='showSybrDetails(&quot;o"+ "&quot;)'>Details</span>";
	} else {
		listHtml += "<span class='sbutton' onclick='showSybrDetails(&quot;f"+ "&quot;)'>Details</span>";
	}
    listHtml += "</div></div>";
    listHtml += "</div>";
}

function addSummaryChartData(e, count, title) {
    costChartStore.getAt(count).set('title', e.get('title'));
    costChartStore.getAt(count).set('name', title);
    costChartStore.getAt(count).set('assay', e.get('assayscostwithvoldisc'));
    costChartStore.getAt(count).set('mastermix', e.get('mastermixcostwithdisc'));
    costChartStore.getAt(count).set('optimization', e.get('optimizedcost'));
    costChartStore.getAt(count).set('total', e.get('totalcost'));
    costChartStore.getAt(count).set('pno', e.get('pno'));
    timeChartStore.getAt(count).set('name', title);
    timeChartStore.getAt(count).set('title', e.get('title'));
    timeChartStore.getAt(count).set('time', e.get('noofhours'));
    timeChartStore.getAt(count).set('pno', e.get('pno'));
}

function loadChartData() {
    var count = 0;
    var costChartStoreundefined = false;
    outputList.each(function (e) {
        //if(costChartStore.getAt(count) == "undefined") costChartStoreundefined = true;
        if (costChartStore.getAt(count)) {
            //console.log("count: "+count + "- costChartStore.getAt(count): " + costChartStore.getAt(count) + " - " + costChartStoreundefined)
            costChartStore.getAt(count).set('title', e.get('title'));
            var title = e.get('title').replace('TaqMan', '').replace('Assays in', '').replace('Made to Order', 'MTO');
            if (getExperimentInfo("type") == "Genotyping") {
                if (e.get('title').indexOf('Custom') != -1) {
                    title = "Custom SNP";
                } else if (e.get('title').indexOf('Drug') != -1) {
                    title = "DME";
                } else {
                    title = "SNP";
                }
            }
            if (e.get('type').indexOf('fixed') != -1 || e.get('type').indexOf('openarray') != -1) {
                if (e.get('format').indexOf('32A') != -1) {
                    title = "32A";
                } else if (e.get('format').indexOf('32B') != -1) {
                    title = "32B";
                } else if (e.get('format').indexOf('64') != -1) {
                    title = "64";
                } else if (e.get('format').indexOf('PGx') != -1) {
                    title = "PGx";
                } else {
                    title = e.get('type');
                }
            }
            if (e.get('type').indexOf('fixed') != -1 || e.get('type').indexOf('openarray-custom') != -1) {
                if (e.get('format').indexOf('Beamer A') != -1) {
                    title = "Beamer A";
                } else if (e.get('format').indexOf('Beamer B') != -1) {
                    title = "Beamer B";
                } else {
                    title = e.get('type');
                }
            }
            costChartStore.getAt(count).set('name', title);
            costChartStore.getAt(count).set('assay', e.get('assayscost'));
            costChartStore.getAt(count).set('mastermix', e.get('mastermixcost'));
            costChartStore.getAt(count).set('optimization', e.get('optimizedcost'));
            costChartStore.getAt(count).set('total', e.get('totalcost'));
            costChartStore.getAt(count).set('pno', e.get('pno'));
            timeChartStore.getAt(count).set('name', title);
            timeChartStore.getAt(count).set('title', e.get('title'));
            timeChartStore.getAt(count).set('time', e.get('noofhours'));
            timeChartStore.getAt(count).set('pno', e.get('pno'));
        }
        count++;
    });
    if (getExperimentInfo("type") == "Gene Expression") {
        costChartStore.getAt(count).set('title', sybr.title);
        costChartStore.getAt(count).set('name', sybr.title);
        costChartStore.getAt(count).set('assay', sybr.assayscost);
        costChartStore.getAt(count).set('mastermix', sybr.mastermixcost);
        costChartStore.getAt(count).set('optimization', sybr.optimizedcost);
        costChartStore.getAt(count).set('total', sybr.totalcost);
        timeChartStore.getAt(count).set('title', sybr.title);
        timeChartStore.getAt(count).set('name', sybr.title);
        timeChartStore.getAt(count).set('time', sybr.noofhours);
        // costChartStore.getAt(++count).set('title', osybr.title);
        // costChartStore.getAt(count).set('name', osybr.title);
        // costChartStore.getAt(count).set('assay', osybr.assayscost);
        // costChartStore.getAt(count).set('mastermix', osybr.mastermixcost);
        // costChartStore.getAt(count).set('optimization', osybr.optimizedcost);
        // costChartStore.getAt(count).set('total', osybr.totalcost);
        // timeChartStore.getAt(count).set('title', osybr.title);
        // timeChartStore.getAt(count).set('name', osybr.title);
        // timeChartStore.getAt(count).set('time', osybr.noofhours);
    }
}

function loadChartDataByInstruement(typelist) {
    var count = 0;
    var costChartStoreundefined = false;
	
	 clearChartData();
	//console.log("-----------------------------------------------")
    outputList.each(function (e) {
		type = e.get('type');
		types = type.split("-");
        if (isValueInArray(types[0], typeSortArray)) {
			if (costChartStore.getAt(count)) {				
				costChartStore.getAt(count).set('title', e.get('title'));
				var title = e.get('title').replace('TaqMan', '').replace('Assays in', '').replace('Made to Order', 'MTO');
				if (getExperimentInfo("type") == "Genotyping") {
					if (e.get('title').indexOf('Custom') != -1) {
						title = "Custom SNP";
					} else if (e.get('title').indexOf('Drug') != -1) {
						title = "DME";
					} else {
						title = "SNP";
					}
				}
				if (e.get('type').indexOf('fixed') != -1 || e.get('type').indexOf('openarray') != -1) {
					if (e.get('format').indexOf('32A') != -1) {
						title = "32A";
					} else if (e.get('format').indexOf('32B') != -1) {
						title = "32B";
					} else if (e.get('format').indexOf('64') != -1) {
						title = "64";
					} else if (e.get('format').indexOf('PGx') != -1) {
						title = "PGx";
					} else {
						title = e.get('type');
					}
				}
				if (e.get('type').indexOf('fixed') != -1 || e.get('type').indexOf('openarray-custom') != -1) {
					if (e.get('format').indexOf('Beamer A') != -1) {
						title = "Beamer A";
					} else if (e.get('format').indexOf('Beamer B') != -1) {
						title = "Beamer B";
					} else {
						title = e.get('type');
					}
				}
				costChartStore.getAt(count).set('name', title);
				costChartStore.getAt(count).set('assay', e.get('assayscost'));
				costChartStore.getAt(count).set('mastermix', e.get('mastermixcost'));
				costChartStore.getAt(count).set('optimization', e.get('optimizedcost'));
				costChartStore.getAt(count).set('total', e.get('totalcost'));
				costChartStore.getAt(count).set('pno', e.get('pno'));
				//(count).set('name', title);
				timeChartStore.getAt(count).set('title', e.get('title'));
				timeChartStore.getAt(count).set('time', e.get('noofhours'));
				timeChartStore.getAt(count).set('pno', e.get('pno'));
				
				count++;
			}
			
		}
    });
    if (getExperimentInfo("type") == "Gene Expression") {
		if (costChartStore.getAt(count)) {
			costChartStore.getAt(count).set('title', sybr.title);
			costChartStore.getAt(count).set('name', sybr.title);
			costChartStore.getAt(count).set('assay', sybr.assayscost);
			costChartStore.getAt(count).set('mastermix', sybr.mastermixcost);
			costChartStore.getAt(count).set('optimization', sybr.optimizedcost);
			costChartStore.getAt(count).set('total', sybr.totalcost);
			timeChartStore.getAt(count).set('title', sybr.title);
			timeChartStore.getAt(count).set('name', sybr.title);
			timeChartStore.getAt(count).set('time', sybr.noofhours);
			// costChartStore.getAt(++count).set('title', osybr.title);
			// costChartStore.getAt(count).set('name', osybr.title);
			// costChartStore.getAt(count).set('assay', osybr.assayscost);
			// costChartStore.getAt(count).set('mastermix', osybr.mastermixcost);
			// costChartStore.getAt(count).set('optimization', osybr.optimizedcost);
			// costChartStore.getAt(count).set('total', osybr.totalcost);
			// timeChartStore.getAt(count).set('title', osybr.title);
			// timeChartStore.getAt(count).set('name', osybr.title);
			// timeChartStore.getAt(count).set('time', osybr.noofhours);
		}	
        
    }
}

function displayChart() {
    if (sortedBy == 0) {
        Ext.get('charttitle').update("<span class='lablebig'>Time to Results</span>");
        displayTimeChart();
    } else {
        Ext.get('charttitle').update("<span class='lablebig'>Experiment Costs</span>");
        displayCostChart();
    }
}

function displayCostChart() {
    Ext.get('chartcont').update("");
    Ext.create('Ext.chart.Chart', {
        renderTo: 'chartcont',
        width: 700,
        height: 600,
        animate: true,
        theme: 'Fancy',
        style: 'background:#fff',
        legend: {
            position: 'bottom'
        },
        gradients: [{
                'id': 'v-1',
                'angle': 90,
                stops: {
                    0: {
                        color: '#4F81BD'
                    },
                    100: {
                        color: '#4F81BD'
                    }
                }
            }, {
                'id': 'v-2',
                'angle': 90,
                stops: {
                    0: {
                        color: '#C0504D'
                    },
                    100: {
                        color: '#C0504D'
                    }
                }
            }, {
                'id': 'v-3',
                'angle': 90,
                stops: {
                    0: {
                        color: '#9BBB59'
                    },
                    100: {
                        color: '#9BBB59'
                    }
                }
            }
        ],
        shadow: true,
        store: costChartStore,
        axes: [{
                type: 'Category',
                position: 'bottom',
                fields: 'name',
                title: false,
                grid: false,
                label: {
                    rotate: {
                        degrees: 0
                    },
                    font: 'bold 10px Arial',
                    renderer: function (v) {
                        return v;
                    }
                },
                roundToDecimal: false
            }, {
                type: 'Numeric',
                position: 'left',
                grid: true,
                fields: ['total'],
                title: false
            }
        ],
        series: [{
                type: 'column',
                axis: 'bottom',
                highlight: true,
                xField: 'total cost',
                yField: ['total'],
                stacked: true,
                tips: {
                    trackMouse: true,
                    width: 65,
                    height: 28,
                    renderer: function (storeItem, item) {
                        this.setTitle(String(item.value[1]));
                    }
                },
                label: {
                    display: 'outside',
                    field: ['total'],
                    renderer: function (v) {
                        return v;
                    },
                    orientation: 'horizontal',
                    minMargin: 1,
                    font: '12px Arial',
                    'text-anchor': 'middle',
                    color: '#333'
                },
                listeners: {
                    itemmousedown: function (o) {
                        var title = "" + o.storeItem.data['pno'];
                        if (title.indexOf("SYBR") == -1) {
                            showDetails(title);
                        } else {
                            showSybrDetails();
                        }
                    }
                }
            }
        ]
    });
}

function displayTimeChart() {
    Ext.get('chartcont').update("");
    Ext.create('Ext.chart.Chart', {
        renderTo: 'chartcont',
        width: 700,
        height: 600,
        animate: true,
        theme: 'Fancy',
        style: 'background:#fff',
        legend: {
            position: 'bottom'
        },
        gradients: [{
                'id': 'v-1',
                'angle': 90,
                stops: {
                    0: {
                        color: '#0686CF'
                    },
                    100: {
                        color: '#00609D'
                    }
                }
            }, {
                'id': 'v-2',
                'angle': 90,
                stops: {
                    0: {
                        color: '#51AF1A'
                    },
                    100: {
                        color: '#207A00'
                    }
                }
            }, {
                'id': 'v-3',
                'angle': 90,
                stops: {
                    0: {
                        color: '#475886'
                    },
                    100: {
                        color: '#233a73'
                    }
                }
            }
        ],
        shadow: true,
        store: timeChartStore,
        axes: [{
                type: 'Category',
                position: 'bottom',
                fields: 'name',
                title: false,
                grid: false,
                label: {
                    rotate: {
                        degrees: 0
                    },
                    font: 'bold 10px Arial',
                    renderer: function (v) {
                        return v;
                    }
                },
                roundToDecimal: false
            }, {
                type: 'Numeric',
                position: 'left',
                grid: true,
                fields: ['time'],
                title: false
            }
        ],
        series: [{
                type: 'column',
                axis: 'bottom',
                highlight: true,
                xField: 'totaltime',
                yField: ['time'],
                stacked: false,
                tips: {
                    trackMouse: true,
                    width: 65,
                    height: 28,
                    renderer: function (storeItem, item) {
                        this.setTitle(String(item.value[1]));
                    }
                },
                label: {
                    display: 'outside',
                    field: ['time'],
                    renderer: Ext.util.Format.numberRenderer('0'),
                    orientation: 'horizontal',
                    minMargin: 1,
                    'text-anchor': 'middle',
                    font: '9px Arial',
                    color: '#333'
                },
                listeners: {
                    itemmousedown: function (o) {
                        var title = "" + o.storeItem.data['pno'];
                        if (title.indexOf("SYBR") == -1) {
                            showDetails(title);
                        } else {
                            showSybrDetails();
                        }
                    }
                }
            }
        ]
    });
}

function roundNumber(rnum, rlength) { // Arguments: number to round, number of
    // decimal places
    var newnumber = Math.round(rnum * Math.pow(10, rlength)) / Math.pow(10, rlength);
    return newnumber;
}

function findGenoTubeRecord(subtype, productname, species) {
    var recordIndex = 0;
    var count = 0;
    genoTypeTubes.each(function (record) {
        if (record.get('subtype') == subtype && record.get('product type') == "Tube" && record.get('species') == species && record.get('productname') == productname) {
            recordIndex = count;
            return false; // a record with this data exists
        }
        count++;
    });
    return genoTypeTubes.getAt(recordIndex);
}

function findOptimumGenoTubeRecord(subtype, species, noofreactions) {
    var recordIndex = 0;
    var price = 0;
    var count = 0;
    genoTypeTubes.each(function (e) {
        if (e.get('subtype') == subtype && e.get('product type') == "Tube" && e.get('species') == species) {
            var equipment = getExperimentInfo('equipment');
            var mnoofunits = 0;
            if (equipment == "96-well") {
                mnoofunits = Math.ceil(noofreactions / e.get('no of reactions in 96-well tube'));
            } else {
                mnoofunits = Math.ceil(noofreactions / e.get('no of reactions in 384-well tube'));
            }
            var partNumber = e.get('partnumber');
            var mprice = mnoofunits * pricelist.findRecord('partnumber', partNumber).regions().findRecord('region', region + "-" + currency).get('price');
            if (price == 0) {
                price = mprice;
                recordIndex = count;
            }
            if (mprice < price) {
                price = mprice;
                recordIndex = count;
            }
        }
        count++;
    });
    return genoTypeTubes.getAt(recordIndex);
}

function findGenoMMXRecord(mvolume) {
    var recordIndex = 0;
    var price = 0;
    var count = 0;
    genoMasterMix.each(function (e) {
        if (!(e.get('assaytype') == "openarray")) {
            var mnoofunits = Math.ceil(mvolume / e.get('volume'));
            var partNumber = e.get('partnumber');
            var mprice = mnoofunits * pricelist.findRecord('partnumber', partNumber).regions().findRecord('region', region + "-" + currency).get('price');
            if (price == 0) {
                price = mprice;
            }
            if (mprice < price) {
                price = mprice;
                recordIndex = count;
            }
            count++;
        }
    });
    return genoMasterMix.getAt(recordIndex);
}

function findMicrnafixedMMXRecord(mvolume) {
    var recordIndex = 0;
    var price = 0;
    var count = 0;
    mirnaMasterMix.each(function (e) {
        var mnoofunits = Math.ceil(mvolume / e.get('volume'));
        var mprice = mnoofunits * e.get('price');
        if (price == 0) {
            price = mprice;
            recordIndex = count;
        }
        if (mprice < price) {
            price = mprice;
            recordIndex = count;
        }
        count++;
    });
    return mirnaMasterMix.getAt(recordIndex);
}

function findMicrnaFixedRTRecord(reactions, specie) {
    specie = (specie == "Rat" || specie == "Mouse") ? "Rodent" : specie;
    var recordIndex = 0;
    var price = 0;
    var count = 0;
    mirnaRT.each(function (e) {
        var rtnoofunits = Math.ceil(reactions / e.get('reactions'));
        var mprice = rtnoofunits * e.get('price');
        if (price == 0 && (specie == e.get('species') || 'Any') == e.get('species')) {
            price = mprice;
            recordIndex = count;
        }
        if (mprice < price && (specie == e.get('species') || 'Any') == e.get('species')) {
            price = mprice;
            recordIndex = count;
        }
        count++;
    });
    return mirnaRT.getAt(recordIndex);
}

function findMicrnaFixedPreAmpRecord(reactions, specie) {
    specie = (specie == "Rat" || specie == "Mouse") ? "Rodent" : specie;
    var recordIndex = 0;
    var price = 0;
    var count = 0;
    mirnaPreAmp.each(function (e) {
        var rtnoofunits = Math.ceil(reactions / e.get('reactions'));
        var mprice = rtnoofunits * e.get('price');
        if (price == 0 && (specie == e.get('species') || 'Any') == e.get('species')) {
            price = mprice;
            recordIndex = count;
        }
        if (mprice < price && (specie == e.get('species') || 'Any') == e.get('species')) {
            price = mprice;
            recordIndex = count;
        }
        count++;
    });
    return mirnaPreAmp.getAt(recordIndex);
}

/*Added by SS*/
function findMicrnaFixedCustPreAmpRecord(format, specie) {
    specie = (specie == "Rat" || specie == "Mouse") ? "Rodent" : specie;
    var recordIndex = 0;
    var price = 0;
    var count = 0;
    custmiRNAPreAmp.each(function (e) {
        /*var rtnoofunits = Math.ceil(reactions / e.get('reactions'));
          var mprice = rtnoofunits * e.get('price');*/
          
        var preampformat = e.get('preampformat');
        if ( preampformat == format) {
            //price = mprice;
            recordIndex = count;
        }
       /* if (mprice < price && (specie == e.get('species') || 'Any') == e.get('species')) {
            price = mprice;
            recordIndex = count;
        }*/
        count++;
    });
    return custmiRNAPreAmp.getAt(recordIndex);
}

function findMicrnaFixedCustRTRecord(format, specie, type) {
    specie = (specie == "Rat" || specie == "Mouse") ? "Rodent" : specie;
    var recordIndex = 0;
    var price = 0;
    var count = 0;
    
    mirnaRT.each(function (e) {
    	var preampformat = e.get('assaytype');
    	if ( preampformat == format && type == e.get('type')) {
            recordIndex = count;
        }
        
        /*var rtnoofunits = Math.ceil(reactions / e.get('reactions'));
        var mprice = rtnoofunits * e.get('price');
        if (price == 0 && (specie == e.get('species') || 'Any') == e.get('species')) {
            price = mprice;
            recordIndex = count;
        }
        if (mprice < price && (specie == e.get('species') || 'Any') == e.get('species')) {
            price = mprice;
            recordIndex = count;
        }*/
        count++;
    });
    return mirnaRT.getAt(recordIndex);
}
/*End by Ss*/

function findOptimumMiRNAExpTubeRecord(noofreactions, type, noofsamples) {
    var recordIndex = 0;
    var price = 0;
    var count = 0;
    tubesModel.each(function (e) {
        var partNumber = e.get('partnumber');
        var isMirna = getExperimentInfo('type') == "Gene Expression" ? false : true;
        var application = getExperimentInfo('type') == "Gene Expression" ? "Gene_" : "miRNA_";
        var factor = (e.get('concatenate').indexOf('Extra') != -1 || e.get('concatenate').indexOf('small') != -1) ? 3 : 1;
        if (e.get('concatenate').indexOf(application) != -1 && e.get('concatenate').indexOf(type) != -1) {
            var mnoofunits = 0;
			var mnoofunits1 = 0;
            if (getExperimentInfo('equipment') == '96-well') {
                mnoofunits = Math.ceil(noofreactions  / e.get('96-wellnumberofreactions'));
				mnoofunits1 = Math.ceil( (noofsamples * (isMirna ? factor : 1)) / e.get('96-wellnumberofreactions'));
            } else if (getExperimentInfo('equipment') == '384-well') {
                mnoofunits = Math.ceil(noofreactions  / e.get('384-wellnumberofreactions'));
				mnoofunits1 = Math.ceil( (noofsamples * (isMirna ? factor : 1)) / e.get('384-wellnumberofreactions'));
            } else {
                mnoofunits = Math.ceil(noofreactions  / e.get('numberofreactions'));
				mnoofunits1 = Math.ceil( (noofsamples * (isMirna ? factor : 1)) / e.get('384-wellnumberofreactions'));
            }
			if(mnoofunits1 > mnoofunits){
				mnoofunits = mnoofunits1;
			}
            var mprice = mnoofunits * pricelist.findRecord('partnumber', partNumber).regions().findRecord('region', region + "-" + currency).get('price');
            if (price == 0) {
                price = mprice;
                recordIndex = count;
            }
            if (mprice < price) {
                price = mprice;
                recordIndex = count;
            }
        }
        count++;
    });
    return tubesModel.getAt(recordIndex);
}

function findOptimumGeneMicroExpTubeRecord(noofreactions, type) {
    var recordIndex = 0;
    var price = 0;
    var count = 0;
    tubesModel.each(function (e) {
        var partNumber = e.get('partnumber');
        var isMirna = getExperimentInfo('type') == "Gene Expression" ? false : true;
        var application = getExperimentInfo('type') == "Gene Expression" ? "Gene_" : "miRNA_";
        var factor = (e.get('concatenate').indexOf('Extra') != -1 || e.get('concatenate').indexOf('small') != -1) ? 3 : 1;
        if (e.get('concatenate').indexOf(application) != -1 && e.get('concatenate').indexOf(type) != -1) {
            var mnoofunits = 0;
            if (getExperimentInfo('equipment') == '96-well') {
                mnoofunits = Math.ceil(noofreactions * (isMirna ? factor : 1) / e.get('96-wellnumberofreactions'));
            } else if (getExperimentInfo('equipment') == '384-well') {
                mnoofunits = Math.ceil(noofreactions * (isMirna ? factor : 1) / e.get('384-wellnumberofreactions'));
            } else {
                mnoofunits = Math.ceil(noofreactions * (isMirna ? factor : 1) / e.get('numberofreactions'));
            }
            var mprice = mnoofunits * pricelist.findRecord('partnumber', partNumber).regions().findRecord('region', region + "-" + currency).get('price');
            if (price == 0) {
                price = mprice;
                recordIndex = count;
            }
            if (mprice < price) {
                price = mprice;
                recordIndex = count;
            }
        }
        count++;
    });
    return tubesModel.getAt(recordIndex);
}

function GetCopyModel() {
    return copyModel.getAt(0);
}
var openArrayGeneExpMasterMixModel = [{
        partnumber: "4462159",
        product: "TaqMan&reg;&nbsp;OpenArray&reg;&nbsp;Real-Time Master Mix, 1.5mL",
        volume: 1500
    }, {
        partnumber: "4462164",
        product: "TaqMan&reg;&nbsp;OpenArray&reg;&nbsp;Real-Time Master Mix, 5mL",
        volume: 5000
    }
];

function findOptimumOpenArrayGeneMicroMMXRecord(mvolume) {
    var recordIndex = 0;
    var price = 0;
    var count = 0;
    for (var i = 0; i < openArrayGeneExpMasterMixModel.length; i++) {
        var mnoofunits = Math.ceil(mvolume / openArrayGeneExpMasterMixModel[i].volume);
        var partNumber = openArrayGeneExpMasterMixModel[i].partnumber;
        var mprice = mnoofunits * pricelist.findRecord('partnumber', partNumber).regions().findRecord('region', region + "-" + currency).get('price');
        if (price == 0) {
            price = mprice;
            recordIndex = count;
        }
        if (mprice < price) {
            price = mprice;
            recordIndex = count;
        }
        count++;
    }
    return openArrayGeneExpMasterMixModel[recordIndex];
}

function findOptimumGeneMicroMMXTubeRecord(mvolume) {
    var recordIndex = 0;
    var price = 0;
    var count = 0;
    var chem = getExperimentInfo('method') == 'Fast' ? "Fast" : "Universal";
	if (getExperimentInfo("type") == "Gene Expression" && chem != "Fast" &&  getExperimentInfo("isPlate") === "plate" ) {
		chem = "Gene Expression";
	}
    masterMixModel.each(function (e) {
        if (e.get('product').indexOf(chem) != -1 && e.get('product').indexOf("TaqMan") != -1) {
            var mnoofunits = Math.ceil(mvolume / e.get('volume'));
            var partNumber = e.get('partnumber');
            var mprice = mnoofunits * pricelist.findRecord('partnumber', partNumber).regions().findRecord('region', region + "-" + currency).get('price');
            if (price == 0) {
                price = mprice;
                recordIndex = count;
            }
            if (mprice < price && mprice != 0) {
                price = mprice;
                recordIndex = count;
            }
        }
        count++;
    });
    return masterMixModel.getAt(recordIndex);
}

function findOptimumSybrMMXRecord(mvolume) {
    var recordIndex = 0;
    var price = 0;
    var count = 0;
    var chem = getExperimentInfo('method') == 'Fast' ? "Fast" : "Power";
    masterMixModel.each(function (e) {
        if (e.get('product').indexOf(chem) != -1 && e.get('product').indexOf("SYBR") != -1) {
            var mnoofunits = Math.ceil(mvolume / e.get('volume'));
			var partNumber = e.get('partnumber');
			var mprice = mnoofunits * pricelist.findRecord('partnumber', partNumber).regions().findRecord('region', region + "-" + currency).get('price');
			//var mprice = mnoofunits * e.regions().findRecord('region', region).prices().findRecord('countrycode', currency).get('value');
			
            if (price == 0) {
                price = mprice;
                recordIndex = count;
            }
            if (mprice < price) {
                price = mprice;
                recordIndex = count;
            }
        }
        count++;
    });
    return masterMixModel.getAt(recordIndex);
}

// PowerUp™ SYBR® Green Master Mix
function findOptimumPowerUpSybrMMXRecord(mvolume) {
    var recordIndex = 0;
    var price = 0;
    var count = 0;
    //var chem = getExperimentInfo('method') == 'Fast' ? "Fast" : "Power";
    masterMixModel.each(function (e) {
        if (e.get('product').indexOf("PowerUp") != -1 && e.get('product').indexOf("SYBR") != -1) {
            var mnoofunits = Math.ceil(mvolume / e.get('volume'));
			var partNumber = e.get('partnumber');
			var mprice = mnoofunits * pricelist.findRecord('partnumber', partNumber).regions().findRecord('region', region + "-" + currency).get('price');
			//var mprice = mnoofunits * e.regions().findRecord('region', region).prices().findRecord('countrycode', currency).get('value');
			
            if (price == 0) {
                price = mprice;
                recordIndex = count;
            }
            if (mprice < price) {
                price = mprice;
                recordIndex = count;
            }
        }
        count++;
    });
    return masterMixModel.getAt(recordIndex);
}

function getRTPrimerPools(species, reactions, type) {
    species = (species == "Rat" || species == "Mouse") ? "Rodent" : species;
    var recordIndex = 0;
    var count = 0;
    var price = 0;
    mirnaRT.each(function (record) {
        if (record.get('species') == species && record.get('type') == "RT Primer" && (record.get("productname").indexOf(type) != -1)) {
            var noofunits = reactions / record.get('reactions');
            var partNumber = record.get('partnumber');
            var mprice = noofunits * pricelist.findRecord('partnumber', partNumber).regions().findRecord('region', region + "-" + currency).get('price');
            if (price == 0) {
                price = mprice;
                recordIndex = count;
            }
            if (mprice < price) {
                price = mprice;
                recordIndex = count;
            }
        }
        count++;
    });
    return mirnaRT.getAt(recordIndex);
}

function getPreAmpPrimerPools(species, reactions, type) {
    species = (species == "Rat" || species == "Mouse") ? "Rodent" : species;
    var recordIndex = 0;
    var count = 0;
    var price = 0;
    mirnaPreAmp.each(function (record) {
        if (record.get('species') == species && record.get('type') == "RT+PreAmp Primer" && (record.get("productname").indexOf(type) != -1)) {
            var noofunits = reactions / record.get('reactions');
            var partNumber = record.get('partnumber');
            var mprice = noofunits * pricelist.findRecord('partnumber', partNumber).regions().findRecord('region', region + "-" + currency).get('price');
            if (price == 0) {
                price = mprice;
                recordIndex = count;
            }
            if (mprice < price) {
                price = mprice;
                recordIndex = count;
            }
        }
        count++;
    });
    return mirnaPreAmp.getAt(recordIndex);
}
function tooltip(obj, id){
	if(id === "samplevalues"){
		var txt = 'Calculations are based on 365 days per year, 52.177 week per year and 12 months per year.'
	} 
	if(id === "magmaxvalues"){
		var txt = 'Enter 0 if you don\'t need DNA extraction solution.'
	}
	if(id === "snpanalysis"){
		var txt = 'To generate a quote for consumable and reagent only, select instrument and format and enter 0 for number of instrument needed.'
	}
	if(id === "accufil"){
		var txt = 'Recommend 1 instrument per QS OpenArray instrument.'
	}
	if(id === "copynumber"){
		var txt = 'To generate a quote for consumable and reagents only, select instrument and format and enter 0 for number of block needed.'
	} 
	if(id === "robots"){
		var txt = 'Only for QuantStudio 12K Flex - not compatible with OpenArray block.'
	} 
	if(id === "iqradiobtn"){
		var txt = 'Content IQ/OQ consists of validation of the specification.'
	}
	if(id === "systemvalidation"){
		var txt = 'Computer system validation consists of…....'
	}
	if(id === "instrumentinstallation"){
		var txt = ' We recommend to select XXX because includes X, Y and Z'
	}
	if(id === "training"){
		var txt = 'Trainings provided with instrument are jfdlkalfjdlak. Select if you need additional training.'
	}
	var tip = Ext.create('Ext.tip.ToolTip', {
		target: id,
		html: txt
	});
}
function GetUnitsPerCradsPlatesArray(partNo, type, isNeeded){

	 var unitData = '';
	 
	 unitQty.each(function (record) {
		 if(record.get('partnumber') == partNo){
		 	unitData = record.get(type);
		 }
	 });
	 
	 if(unitData.length == 0 && isNeeded){
	 	mirnaAccessories.each(function (record) {
			if(record.get('partnumber') == partNo){
			 	unitData = record.get('noofitemsinpack');
			}
	 	});
	 }
	 
	 if(unitData.length == 0 && isNeeded){
	 	quantstudio.each(function (record) {
			if(record.get('partnumber') == partNo){
			 	unitData = record.get('Min Order');
			 	if(unitData.length != 0 && (unitData.split('x')).length > 1){
				 	unitData = unitData.split('x')[1];
				}
				unitData = unitData.replace('-', ' ');
			}
	 	});
	 }
	 if(unitData.length == 0){
		 unitData = 'NO';
	 }
	 if(unitData.length != 0 && unitData != 'NO'){
	 	var temp = unitData.split('')[0];
	 	if(parseInt(temp) > 1){
	 		unitData = unitData+'s';
	 	}
	 }
	 return unitData;
}

function getProductURL(partNumber, productURL){
	var productUrl = null;
	try{
		productUrl =  producturls.findRecord('partNumber', partNumber).get('productURL');
		if(productUrl == "NA"){
			return productURL;
		}else{
			return productUrl;
		}
	}catch(e){
		return productURL;
	}
}

function displayListBasedOnConsumables(val){
	var selConsum = getExperimentInfo("tubeSel");
	var bReturn = false;
	var strConsumable = "";
	updateExperimentInfo("isPlate", "None");
	if(selConsum === "All" ){
		updateExperimentInfo("isPlate", "None");
		strConsumable = "All";
	}else if(selConsum === "Tube" ){
		strConsumable = "tube";
	}else if(selConsum === "TAPFast" ){
		updateExperimentInfo("isPlate", "plate");
		strConsumable = "plate";
	}else if(selConsum === "TAPStandard" ){
		updateExperimentInfo("isPlate", "plate");
		strConsumable = "plate";
	}else if(selConsum === "TAC" ){
		strConsumable = "card";
	}else if(selConsum === "OpenArray" ){
		strConsumable = "openarray";
	}else if(selConsum === "Chips" ){
		strConsumable = "chips";
	}
	
	if( strConsumable === val || strConsumable === "All" ) {
		bReturn = true;
	} else if( strConsumable === val ) {
		bReturn = true;
	}
	
	return bReturn;
}

function findAppTapRecForOtherFormat(object, formatname, formatVal){
	var record = null;
	return object.findRecord(formatname, formatVal);
}
function findAppTapRecForOtherMMFormat(object, formatname, formatVal){
	var record = null;
	var chem = getExperimentInfo('method') == 'Fast' ? "Fast" : "Universal";
	if (getExperimentInfo("type") == "Gene Expression" && chem != "Fast" &&  getExperimentInfo("isPlate") === "plate" ) {
		chem = "Gene Expression";
	}
	record = object.findRecord(formatname, formatVal);
	//object.each(function(e) {
	//	record = object.findRecord(formatname, formatVal);
		//if (e.get('product').indexOf(chem) != -1 && e.get('product').indexOf("TaqMan") != -1) {
		/*if (e.get('product').indexOf("TaqMan") != -1) {
			if(e.get(formatname) === Number(formatVal)){
				record =  e;
			}
		}*/
	//});
	return record;

}

// Find other SYBR MM 
function findAppSybrRecForOtherMMFormat(object, formatname, formatVal){
	var record = null;	
	record = object.findRecord(formatname, formatVal);	
	return record;
}

function ViewDetails( selTitle, obj, formatType ){
	//var grid = Ext.getCmp('steptwo');
	//grid.el.mask('', 'x-mask-loading');
	$("#overlay").show().css('z-index','99');
	$("body").css('overflow','hidden');
	var id = $(obj).val().split("_");
	//$(".popArrow").css({'left':'-15px','top':'296px'});
	var selApplication = getExperimentInfo("type");
	var objCardPlates = null;
	var getTypeVal = "";
	var getComFormatTp = "";
	var filterType = "";
	var functionName = "";
	var rec = outputList.findRecord('pno', id[2], 0, false, false, true);
	var genoExcept = "Null"; 
	if(selApplication === "Gene Expression" ){
		if( formatType.indexOf('card') != -1 ){
			objCardPlates = tacTapHelper;
			//filterType = "Card";
			filterType=new RegExp("^.*Card.*","gi"); 
			functionName = rec.get('fnName');
			getTypeVal = "tacname";
			getComFormatTp= "tacname";
		}else if( formatType.indexOf('plate') != -1 ){
			objCardPlates = platesCardsModel;
			//filterType = "Plate";
			filterType=new RegExp("^.*Plate.*","gi"); 
			functionName =  rec.get('fnName');
			getTypeVal = "description";
			getComFormatTp= "assay";
		} else if( formatType.indexOf('tube') != -1 ){
			objCardPlates = tubesModel;
			var arraytem = selTitle.split(",");
			if(selTitle.indexOf("Custom Plus") != -1){
				filterType = new RegExp("^.*(Custom Plus.*)(RNA.*)","gi");
				objCardPlates = plusRNAModel;
			}else{
				filterType = new RegExp("^.*(Gene.*)("+$.trim(arraytem[arraytem.length-1])+".*)","gi");
			}
			functionName =  rec.get('fnName');
			getTypeVal = "concatenate";
			getComFormatTp= "concatenate";
		}
	}else if(selApplication === "miRNA"){
		if( formatType.indexOf('card') != -1 ){
			objCardPlates = taccustmiRNA;
			//filterType = "Card";
			filterType=new RegExp("^.*Card.*","gi"); 
			functionName =  rec.get('fnName');
			getTypeVal = "tacname";
			getComFormatTp = "tacformat";
		} else if( formatType.indexOf('tube') != -1 ){
			objCardPlates = tubesModel;
			var arraytem = selTitle.split(",");
			filterType = new RegExp("^.*(miRNA.*)("+$.trim(arraytem[arraytem.length-1])+".*)","gi");
			functionName =  rec.get('fnName');
			getTypeVal = "concatenate";
			getComFormatTp= "concatenate";
		}
		
	}else if(selApplication === "Genotyping"){
		if( formatType.indexOf('tube') != -1 ){
			objCardPlates = genoTypeTubes;
			var arraytem = selTitle.split(",");
			var formatqnt = $.trim(arraytem[0]).replace("TaqMan®","TaqMan");
			if(formatqnt.startsWith("TaqMan")){
				genoExcept = "Custom TaqMan";
			}
			filterType = new RegExp("^.*("+formatqnt+".*)("+$.trim(arraytem[1])+".*)","g");
			functionName =  rec.get('fnName');
			getTypeVal = "productname";
			getComFormatTp = "productname";
		}
		
	}else if(selApplication === "Copy Number"){
		if( formatType.indexOf('tube') != -1 ){
			objCardPlates = copyModel;
			var arraytem = selTitle.split(",");
			var formatqnt = $.trim(arraytem[0]).replace("TaqMan®","TaqMan");
			filterType = new RegExp("^.*("+formatqnt+".*)("+$.trim(arraytem[1])+".*)","gi");
			functionName =  rec.get('fnName');
			getTypeVal = "concatenate";
			getComFormatTp = "concatenate";
		}
	}else if(selApplication === "Mutation Detection"){
		if( formatType.indexOf('tube1') != -1 ){
			objCardPlates = copyModel;
			var arraytem = selTitle.split(",");
			var formatqnt = $.trim(arraytem[0]).replace("TaqMan®","TaqMan");
			filterType = new RegExp("^.*("+formatqnt+".*)("+$.trim(arraytem[1])+".*)","gi");
			functionName =  rec.get('fnName');
			getTypeVal = "concatenate";
			getComFormatTp = "concatenate";
		}
	}
	var imageSrc = "";
	if(id[1] === "viewParntDiv"){
		imageSrc = "popArrowLft.png";
	}else{
		imageSrc = "popArrow.png"
	}
	
	var viewDet = '';
	viewDet = viewDet + '<div class="viewDetailCont" id="" >';
	viewDet = viewDet + 	'<img src="images/'+imageSrc+'" class="popArrow" />';
	viewDet = viewDet +		'<div class="ivgnModal-close"><a class="" href="javascript:void(0);" rel="'+id[1]+'" onclick="closeView(this)"><span class="closeTxt">CLOSE</span> <b class="clSym">&#215</b></a></div>';
	viewDet = viewDet +		'<div class="detInner">';
	viewDet = viewDet +			'<div class="viewTableParnt">';
	viewDet = viewDet +				'<table class="viewTable">';
	viewDet = viewDet +					'<thead>';
	viewDet = viewDet +						'<tr class="tbhead">';
	viewDet = viewDet +							'<th >';
	viewDet = viewDet +								'Cat#';
	viewDet = viewDet +							'</th >';
	viewDet = viewDet +							'<th >';
	viewDet = viewDet +								'Size';
	viewDet = viewDet +							'</th >';
	viewDet = viewDet +							'<th >';
	viewDet = viewDet +								'List Price';
	viewDet = viewDet +							'</th >';
	viewDet = viewDet +							'<th >';
	viewDet = viewDet +								'Qty';
	viewDet = viewDet +							'</th >';
	viewDet = viewDet +							'<th >';
	viewDet = viewDet +								'Select';
	viewDet = viewDet +							'</th >';
	if(id[1] === "viewParntDiv"){
		/*viewDet = viewDet +							'<th >';
		viewDet = viewDet +								'Select';
		viewDet = viewDet +							'</th >';*/
	}
	viewDet = viewDet +						'</tr>';
	viewDet = viewDet +					'</thead>';
	viewDet = viewDet +					'<tbody>';
	
	var wholeCurrTubSel = getExperimentInfo('tubeSel');
	if(id[1] != "viewParntDiv"){
		if(wholeCurrTubSel == "All"){
			if(id[3] === "Fast"){
				updateExperimentInfo("tubeSel", "TAPFast");
			}
		}
	}
	var cnt = 0;
	var ArrPartNo = [];
	objCardPlates.each(function(e) {
		//if( selTitle.indexOf("Format "+e.get(getComFormatTp)) == -1 && (e.get(getTypeVal).indexOf(filterType) != -1) ){
		if( selTitle.indexOf(e.get(getComFormatTp)) == -1 && (e.get(getTypeVal).match(filterType))){
			var val = true;
			if( (selApplication === "Genotyping") && (e.get(getTypeVal).startsWith(genoExcept))){
				return true;
			}
			if('Plate'.match(filterType)){
				if(tacTapHelper.findRecord('tapformat', e.get(getComFormatTp)) == null){
					val = false;
				}
			}
			if(val){
				if(outputList.findExact('pno',getExperimentInfo("otherFmPano")) != -1){
					outputList.removeAt(outputList.findExact('pno',getExperimentInfo("otherFmPano")));
				}
				updateExperimentInfo("isOtherFormat", "YES");
				updateExperimentInfo("selOtherFormatValue", e.get(getComFormatTp));
				updateExperimentInfo("otherFmPano", "111");
				eval( '('+functionName+'())' );
				var rec = outputList.findRecord('pno', getExperimentInfo("otherFmPano"), 0, false, false, true);
				if($.inArray(rec.get("partnumber"),ArrPartNo) == -1){
					ArrPartNo.push(rec.get("partnumber"));
				if(rec.get("format") != selTitle){
					cnt ++;
					viewDet = viewDet +						'<tr class="">';
					viewDet = viewDet +							'<td>';
					viewDet = viewDet +								'<a href="" class="catLink">'+rec.get("partnumber")+'</a>';
					viewDet = viewDet +							'</td>';
					viewDet = viewDet +							'<td>';
					viewDet = viewDet +								rec.get("format");
					viewDet = viewDet +							'</td>';
					viewDet = viewDet +							'<td class="regPrice">';
					viewDet = viewDet +								convertCurrency( (pricelist.findRecord('partnumber', rec.get("partnumber")).regions().findRecord('region', region + "-" + currency).get('price')), region + "-" + currency);
					viewDet = viewDet +							'</td>';
					viewDet = viewDet +							'<td>';
					viewDet = viewDet +								rec.get("noofunits");
					viewDet = viewDet +							'</td>';
					if(id[1] === "viewParntDiv"){
						viewDet = viewDet +							'<td>';
						viewDet = viewDet +								'<input type="button" class="editDet" value="Select" val="'+e.get(getComFormatTp)+'" onclick="checkFn(this);" />';
						viewDet = viewDet +							'</td>';
					}else{
						viewDet = viewDet +							'<td>';
						viewDet = viewDet +								'<input type="button" class="editDet" value="Select" val="'+e.get(getComFormatTp)+'_id_'+id[2]+'" onclick="calSelFormatOutput(this);" />';
						viewDet = viewDet +							'</td>';
					}
					viewDet = viewDet +						'</tr>';
				}
			}
		}
		}
	});
	
	viewDet = viewDet +					'</tbody>';
	viewDet = viewDet +				'</table>';
	
	//$("#"+id[0]).show();
	if(cnt == 0){
		viewDet = '';
		viewDet = viewDet + '<div class="viewDetailCont viewDetailContHead" id="" >';
		viewDet = viewDet + 	'<img src="images/'+imageSrc+'" class="popArrow" />';
		viewDet = viewDet +		'<div class="ivgnModal-close"><a class="" href="javascript:void(0);" rel="'+id[1]+'" onclick="closeView(this)"><span class="closeTxt">CLOSE</span> <b class="clSym">&#215</b></a></div>';
		viewDet = viewDet +		'<div class="detInner">';
		viewDet = viewDet +			'<div class="viewTableParnt viewTableParntHead">';
		viewDet = viewDet +			 '<span>No other formats found for the selected product.</span>';
	}
	viewDet = viewDet +			'</div>';
	viewDet = viewDet +		'</div>';
	viewDet = viewDet + '</div>';
	$("#"+id[1]).html(viewDet);
	$("#"+id[1]).show();
	updateExperimentInfo("tubeSel", wholeCurrTubSel);
	updateExperimentInfo("isOtherFormat", "NO");
}
function closeView(obj){
	var closeId = $(obj).attr('rel');
	$("#"+closeId).hide();
	$("#overlay").hide().css('z-index','99999999');
	$("body").css('overflow','auto');
}
function checkFn(obj){
	$("#overlay").hide();
	var obj1 = $( obj ).attr("val");
	var rec = outputList.findRecord('pno', currentpno, 0, false, false, true);
	updateExperimentInfo("isOtherFormat", "YES");
	updateExperimentInfo("selOtherFormatValue", obj1);
	updateExperimentInfo("otherFmPano", "111");
	var currTargets = $( "#no_of_targets_3" ).val();
	if(currTargets == ''){
		currTargets = getExperimentInfo("nooftargets");
	}
	if( Number(obj1) < Number(currTargets) ){
		Ext.Msg.confirm("Confirm", "Would you like to change the Input target to " +obj1+" ?" , function(e){
			if(e == 'yes'){
				$( "#no_of_targets_3" ).val(obj1);
				$("#nomtragets").html(obj1);
				if(outputList.findExact('pno',getExperimentInfo("otherFmPano")) != -1){
					outputList.removeAt(outputList.findExact('pno',getExperimentInfo("otherFmPano")));
				}
				var functionName  = rec.get('fnName');
				eval( '('+functionName+'())' );
				showDetails(getExperimentInfo('otherFmPano'));
				$("#viewDetailCont").hide();
			}
		});
	}else{
		if(outputList.findExact('pno',getExperimentInfo("otherFmPano")) != -1){
			outputList.removeAt(outputList.findExact('pno',getExperimentInfo("otherFmPano")));
		}
		var functionName  = rec.get('fnName');
		eval( '('+functionName+'())' );
		showDetails(getExperimentInfo('otherFmPano'));
		$("#viewDetailCont").hide();
	}
}

function ViewOtherMMDetails(selTitle, masterTitle, spno){
	$("#viewMMParntDiv").html("");
	$("#overlay").show().css('z-index','99');
	$("body").css('overflow','hidden');
	//$(".popArrow").css({'left':'-15px','top':'313px'});
	var selApplication = getExperimentInfo("type");
	var objCardPlates = null;
	var getTypeVal = "";
	var getComFormatTp = "";
	var filterType = "";
	var functionName = "";
	if( selTitle.indexOf('SYBR') != -1 ){
		var rec = sybr;
	} else {
	var rec = outputList.findRecord('pno', spno, 0, false, false, true);
	}
	if(selApplication === "Gene Expression" ){
		if( selTitle.indexOf('Card') != -1 ){
			objCardPlates = masterMixModel;
			filterType = "Card";
			functionName = rec.get('fnName');
			getTypeVal = "product";
			getComFormatTp= "volume";
		}else if( selTitle.indexOf('Plate') != -1 ){
			objCardPlates = masterMixModel;
			filterType = "Plate";
			functionName = rec.get('fnName');;
			updateExperimentInfo("isPlate", "plate");
			getTypeVal = "product";
			getComFormatTp= "volume";
		} else if( selTitle.indexOf('SYBR') != -1 ){
			objCardPlates = masterMixModel;
			filterType = "SYBR";
			functionName = rec.fnName;
			updateExperimentInfo("isPlate", "plate");
			getTypeVal = "product";
			getComFormatTp= "volume";
		} else if( selTitle.indexOf('Assay') != -1 || selTitle.indexOf('tube') != -1 || selTitle.indexOf('assay') != -1 ){
			objCardPlates = masterMixModel;
			filterType = "tube";
			functionName = rec.get('fnName');
			getTypeVal = "product";
			getComFormatTp= "volume";
		}
		
	}else if(selApplication === "miRNA" ){
		if( selTitle.indexOf('Assay') != -1 || selTitle.indexOf('tube') != -1 || selTitle.indexOf('assay') != -1 ){
			objCardPlates = masterMixModel;
			filterType = "tube";
			functionName = rec.get('fnName');
			getTypeVal = "product";
			getComFormatTp= "volume";
		} else if( selTitle.indexOf('Card') != -1 ){
			objCardPlates = mirnaMasterMix;
			filterType = "Card";
			functionName = rec.get('fnName');
			getTypeVal = "productname";
			getComFormatTp= "volume";
		}
	}else if(selApplication === "Genotyping" ){
		if( selTitle.indexOf('Assay') != -1 || selTitle.indexOf('SNP') != -1 || selTitle.indexOf('assay') != -1 ){
			objCardPlates = genoMasterMix;
			filterType = "tube";
			functionName = rec.get('fnName');
			getTypeVal = "productname";
			getComFormatTp= "volume";
		}
	}else if(selApplication === "Copy Number" ){
		if( selTitle.indexOf('Assay') != -1 || selTitle.indexOf('assays') != -1 || selTitle.indexOf('assay') != -1 ){
			objCardPlates = cnvMasterMix;
			filterType = "tube";
			functionName = rec.get('fnName');
			getTypeVal = "productname";
			getComFormatTp= "volume";
		}
	}else if(selApplication === "Mutation Detection" ){
		if( selTitle.indexOf('Assay') != -1 || selTitle.indexOf('assays') != -1 || selTitle.indexOf('assay') != -1 ){
			objCardPlates = genoMasterMix;
			filterType = "tube";
			functionName = rec.get('fnName');
			getTypeVal = "productname";
			getComFormatTp= "volume";
		}
	}
	var viewDet = '';
	viewDet = viewDet + '<div class="viewDetailCont" id="" >';
	viewDet = viewDet + 	'<img src="images/popArrowLft.png" class="popArrow" />';
	viewDet = viewDet +		'<div class="ivgnModal-close"><a class=""  href="javascript:void(0);" rel="viewMMParntDiv" onclick="closeView(this)"><span class="closeTxt">CLOSE</span> <b class="clSym">&#215</b></a></div>';
	viewDet = viewDet +		'<div class="detInner">';
	viewDet = viewDet +			'<div class="viewTableParnt">';
	viewDet = viewDet +				'<table class="viewTable">';
	viewDet = viewDet +					'<thead>';
	viewDet = viewDet +						'<tr class="tbhead">';
	viewDet = viewDet +							'<th >';
	viewDet = viewDet +								'Cat#';
	viewDet = viewDet +							'</th >';
	viewDet = viewDet +							'<th >';
	viewDet = viewDet +								'Size';
	viewDet = viewDet +							'</th >';
	viewDet = viewDet +							'<th >';
	viewDet = viewDet +								'List Price';
	viewDet = viewDet +							'</th >';
	viewDet = viewDet +							'<th >';
	viewDet = viewDet +								'Qty';
	viewDet = viewDet +							'</th >';
	viewDet = viewDet +							'<th >';
	viewDet = viewDet +								'Select';
	viewDet = viewDet +							'</th >';
	viewDet = viewDet +						'</tr>';
	viewDet = viewDet +					'</thead>';
	viewDet = viewDet +					'<tbody>';
	 
    var chem = getExperimentInfo('method') == 'Fast' ? "Fast" : "Universal";
	if (getExperimentInfo("type") == "Gene Expression" && chem != "Fast" &&  getExperimentInfo("isPlate") === "plate" ) {
		chem = "Gene Expression";
	}
	var isOtherFormat = getExperimentInfo('isOtherFormat');
	var isOtherFM = false;
	
	if( isOtherFormat === "YES" ){
		isOtherFM = true;
	}else{
		isOtherFM = false;
	}
	var fliterArray = [];
	if( (getExperimentInfo("type") == "Gene Expression") ){
		if ( (getExperimentInfo('method') == 'Fast') ){
			fliterArray = ['TaqMan® Gene Expression Master Mix','TaqMan® Universal Master Mix II, with UNG','TaqMan® Universal Master Mix II no UNG','TaqMan® Fast Advanced'];
		}  else if ((getExperimentInfo('method') == 'Standard') ){
			fliterArray = ['TaqMan® Gene Expression Master Mix','TaqMan® Universal Master Mix II, with UNG','TaqMan® Universal Master Mix II no UNG'];
		} 
		if( selTitle.indexOf('SYBR') != -1 ){
			fliterArray = ['SYBR®'];
		}
	} else {
		fliterArray = ['TaqMan® Gene Expression Master Mix','TaqMan® Universal Master Mix II, with UNG','TaqMan® Universal Master Mix II no UNG','TaqMan® Fast Advanced'];
	}
	
	//var fliterArrName=[{'Gene'}];
	var filterVal = [];
	if(selApplication === "miRNA"  || selApplication === "Gene Expression" ){
		if( (selTitle.indexOf('Assays') != -1 || selTitle.indexOf('Assay') != -1 || selTitle.indexOf('Tube') != -1) && (selApplication === "miRNA")){
			for(var fa = 0; fa < fliterArray.length; fa++){
				if(masterTitle.indexOf(fliterArray[fa]) != -1){
					filterVal.push(fliterArray[fa]);
					fliterArray = [];
					fliterArray = filterVal;
				}
			}
		}
		if(selApplication === "miRNA" && selTitle.indexOf('Card') != -1){
			fliterArray = ['TaqMan® Universal Master Mix II, no UNG'];
		}
		for( var b = 0; b < fliterArray.length; b++){
			viewDet = viewDet +	'<tr class="tbhead">';
			viewDet = viewDet +		'<td colspan="5">';
			viewDet = viewDet +			fliterArray[b];
			viewDet = viewDet +		'</td>';
			viewDet = viewDet +	'</tr>';
			objCardPlates.each(function (e) {
				updateExperimentInfo("isOtherMMFormat", "YES");
					//console.log(fliterArray[fa] +" === " + e.get(getTypeVal) +" === " +e.get(getTypeVal).indexOf(fliterArray[fa]));
					//if (e.get('product').indexOf(chem) != -1 && e.get('product').indexOf("TaqMan") != -1) {
				if( (e.get(getTypeVal).indexOf(fliterArray[b]) != -1)&& (e.get(getTypeVal).indexOf("TaqMan") != -1 || e.get(getTypeVal).indexOf(fliterArray[b]) != -1)){
						if(isOtherFM){
							updateExperimentInfo("isOtherFormat", "YES");
						}
						if( selTitle.indexOf('SYBR') == -1 ){
						if(outputList.findExact('pno',getExperimentInfo("otherFmPano")) != -1){
							outputList.removeAt(outputList.findExact('pno',getExperimentInfo("otherFmPano")));
						}
						} else {
							sybr = null;
							outputList.removeAt(outputList.findExact('pno',14));
						}
						updateExperimentInfo("selOtherFormatMMProd",e.get(getTypeVal));
						updateExperimentInfo("selOtherFormatMMValue", e.get(getComFormatTp));
						updateExperimentInfo("otherFmPano", "111");
						eval( '('+functionName+'())' );
						if( selTitle.indexOf('SYBR') != -1 ){
							sybr = getSYBR();
							var rec = sybr;
							outputList.add(rec);
							var rec = outputList.findRecord('pno', 14, 0, false, false, true);
						}else{
						var rec = outputList.findRecord('pno', getExperimentInfo("otherFmPano"), 0, false, false, true);
						}
					if( $.trim(rec.get("mastermix")) != $.trim(masterTitle) ){
						viewDet = viewDet +						'<tr class="">';
						viewDet = viewDet +							'<td>';
						viewDet = viewDet +								'<a href="" class="catLink">'+rec.get("mastermixpartnumber")+'</a>';
						viewDet = viewDet +							'</td>';
						viewDet = viewDet +							'<td>';
						viewDet = viewDet +								rec.get("mastermix");
						viewDet = viewDet +							'</td>';
						viewDet = viewDet +							'<td class="regPrice">';
						viewDet = viewDet +								convertCurrency( (pricelist.findRecord('partnumber', rec.get("mastermixpartnumber")).regions().findRecord('region', region + "-" + currency).get('price')), region + "-" + currency);
						viewDet = viewDet +							'</td>';
						viewDet = viewDet +							'<td>';
						viewDet = viewDet +								rec.get("mnoofunits");
						viewDet = viewDet +							'</td>';
						viewDet = viewDet +							'<td>';
							viewDet = viewDet +								'<input type="button" class="editDet" value="Select"  val="'+e.get(getComFormatTp)+'__'+rec.get("mastermix")+'" onclick="checkFnMM(this);" />';
						viewDet = viewDet +							'</td>';
						viewDet = viewDet +						'</tr>';
					}
				}
			});
		}
	} else {
		objCardPlates.each(function (e) {
			updateExperimentInfo("isOtherMMFormat", "YES");
			if(isOtherFM){
				updateExperimentInfo("isOtherFormat", "YES");
			}
			if(outputList.findExact('pno',getExperimentInfo("otherFmPano")) != -1){
				outputList.removeAt(outputList.findExact('pno',getExperimentInfo("otherFmPano")));
			}
			updateExperimentInfo("selOtherFormatMMProd",e.get(getTypeVal));
			updateExperimentInfo("selOtherFormatMMValue", e.get(getComFormatTp));
			updateExperimentInfo("otherFmPano", "111");			
			eval( '('+functionName+'())' );
			if ( e.get(getTypeVal).indexOf("OpenArray") == -1 ){
				var rec = outputList.findRecord('pno', getExperimentInfo("otherFmPano"), 0, false, false, true);
				if( $.trim(rec.get("mastermix")) != $.trim(masterTitle) ){
					viewDet = viewDet +						'<tr class="">';
					viewDet = viewDet +							'<td>';
					viewDet = viewDet +								'<a href="" class="catLink">'+rec.get("mastermixpartnumber")+'</a>';
					viewDet = viewDet +							'</td>';
					viewDet = viewDet +							'<td>';
					viewDet = viewDet +								rec.get("mastermix");
					viewDet = viewDet +							'</td>';
					viewDet = viewDet +							'<td class="regPrice">';
					viewDet = viewDet +								convertCurrency( (pricelist.findRecord('partnumber', rec.get("mastermixpartnumber")).regions().findRecord('region', region + "-" + currency).get('price')), region + "-" + currency);
					viewDet = viewDet +							'</td>';
					viewDet = viewDet +							'<td>';
					viewDet = viewDet +								rec.get("mnoofunits");
					viewDet = viewDet +							'</td>';
					viewDet = viewDet +							'<td>';
					viewDet = viewDet +								'<input type="button" class="editDet" value="Select"  val="'+e.get(getComFormatTp)+'__'+rec.get("mastermix")+'" onclick="checkFnMM(this);" />';
					viewDet = viewDet +							'</td>';
					viewDet = viewDet +						'</tr>';
				}
			}
		});
	}
	viewDet = viewDet +					'</tbody>';
	viewDet = viewDet +				'</table>';
	viewDet = viewDet +			'</div>';
	viewDet = viewDet +		'</div>';
	viewDet = viewDet + '</div>';
	
	$("#viewMMParntDiv").html(viewDet);
	$("#viewMMParntDiv").show();
	updateExperimentInfo("isOtherFormat", "NO");
}
function checkFnMM(obj){
	$("#overlay").hide();
	var obj1 = ($(obj).attr("val")).split("__");
	var selTitle = obj1[1];
	if( selTitle.indexOf('SYBR') != -1 ){
		sybr = getSYBR();
		var rec = sybr;
		outputList.add(rec);
		var rec = outputList.findRecord('pno', 14, 0, false, false, true);
	}else{
	var rec = outputList.findRecord('pno', currentpno, 0, false, false, true);
	}
						
	
	var isOtherFormat = getExperimentInfo('isOtherFormat');
	var isOtherFM = false;
	
	if( isOtherFormat === "YES" ){
		isOtherFM = true;
		updateExperimentInfo("isOtherFormat", "YES");
	}else{
		isOtherFM = false;
	}
	updateExperimentInfo("selOtherFormatMMProd", obj1[1]);
	updateExperimentInfo("selOtherFormatMMValue", obj1[0]);
	updateExperimentInfo("otherFmPano", "111");
	
	if( selTitle.indexOf('SYBR') == -1 ){
	if(outputList.findExact('pno',getExperimentInfo("otherFmPano")) != -1){
		outputList.removeAt(outputList.findExact('pno',getExperimentInfo("otherFmPano")));
	}
	} else {
		sybr = null;
		outputList.removeAt(outputList.findExact('pno',14));
	}
						
	
	var functionName  = rec.get('fnName');
	eval( '('+functionName+'())' );
	if(functionName == "getSYBR"){
		sybr = getSYBR();
		//displaySYBR('n');		
		showSybrDetails('n');
	} else {
	showDetails(getExperimentInfo('otherFmPano'));
	}
	$("#viewMMParntDiv").hide();
}

/* Edit input values in details page*/
function editInputsNew(){
	 Ext.get('detailoverview').addCls('hidden');
     Ext.get('detailoverview').removeCls('visible');
	 
	Ext.get('editinputs').addCls('visible');
    Ext.get('editinputs').removeCls('hidden');
	 
	var openarrayinstrument = getExperimentInfo("openarrayinstrument") + " &nbsp; &nbsp;";
	//Ext.get('openarrayinstrumentspn').update(openarrayinstrument);
	
	var method = '';
	var chemHtml = "";
	var fastselected = "";
	var stdselected = "";
	if (getExperimentInfo("type") == 'Gene Expression'){
		$('#chemddl').show();
		method = getExperimentInfo("method");
		if(method === "Fast"){
			//fastselected = "selected";
			$('select[name^="edit_chemistrymethod"] option[value="Fast"]').attr("selected","selected");
		}else{
			//stdselected = "selected";	
			$('select[name^="edit_chemistrymethod"] option[value="Standard"]').attr("selected","selected");
		}
		//chemHtml = "<span class='removeEditDrop selectDrop spinMargRight'><select class='removeEditDrop select editDrop' id='edit_chemistrymethod'><option value='Fast' "+fastselected+" >Fast Chemistry</option><option value='Standard' "+stdselected+">Standard Chemistry</option></select></span>";
		
		method = getExperimentInfo("method") + " Chemistry &nbsp; &nbsp; ";
	} else {
		$('#chemddl').hide();
	}
	
	var nomtragets = getExperimentInfo("nooftargets");
	var nomsamples = getExperimentInfo("noofsamples");
	var nomplicat = getExperimentInfo("noofreplicates");
	
	
	$("#no_of_targets_3").val($("#nomtragets").html());
	$("#no_of_samples_3").val($("#nomsamples").html());
	$("#no_of_replicates_3").val($("#nomplicat").html());
	if(getExperimentInfo("type") == "Mutation Detection"){
		$("#spn_referance_targets_3").show();
		$("#no_of_referance_targets_3").val($("#noofreftargets").html());
	} else {
		$("#spn_referance_targets_3").hide();
	}
	
	
	var inputs = "";
	//inputs = chemHtml+"<input class='editInputSpinner editInputSpinnerEr' id='no_of_targets_3' value="+nomtragets+" type='text'/><span class='spinMargRight'> targets</span><input class='editInputSpinner' id='no_of_samples_3' value="+nomsamples+" type='text'/><span class='spinMargRight'> samples </span><input class='editInputSpinner' id='no_of_replicates_3' value="+nomplicat+" type='text'/><span class='spinMargRight'> replicates</span>";
							
	var equipment = getExperimentInfo('equipment');
	var format96 = ""
	var format384 = ""
	if(equipment === "96-well"){
		format96 = "selected";
		$('select[name^="edit_formatwell"] option[value="96-well"]').attr("selected","selected");
	}else{
		format384 = "selected";
		$('select[name^="edit_formatwell"] option[value="384-well"]').attr("selected","selected");
	}
	
	var list = '';
	//list = "<span class='removeEditDrop selectDrop'><select class='removeEditDrop select editDrop' id='edit_formatwell'><option value='96-well' "+ format96 +" >96-well format </option><option value='384-well' "+ format384 +">384-well format</option></select></span><span ><input type='button' class='editDet' value='Update' id='submitEditedInput' onclick='submitEditInputs();' style='padding:3px 13px;'</span><div class='clearfix'></div><span id='errtarget' class='errtargetspn'></span>";
	
	$("#editInputBt").hide();
	$("#submitEditedInput").show();
	
	$("#inputcntrls").show();
	//Ext.get('inputcntrls').append(list);
	//$('#inputcntrls').append(list);
	$(".removeEditDrop").removeClass("selectDrop");
	$(".removeEditDrop").removeClass("editDrop");
	$( ".editInputSpinner" ).spinner({ min: 0, max: 10000, step: 1});	
}

function editInputs(){		
	$( "#no_of_targets_3" ).prop( "disabled", false );
	$( "#no_of_samples_3" ).prop( "disabled", false );
	$( "#no_of_replicates_3" ).prop( "disabled", false );
	$(".removeEditDrop").removeClass("selectDrop");
	$(".removeEditDrop").removeClass("editDrop");
	$( ".editInputSpinner" ).spinner({ min: 0, max: 10000, step: 1});
	$("#editInputBt").hide();
	$("#submitEditedInput").show();
}
function submitEditInputs(){
	
	Ext.get('editinputs').addCls('hidden');
    Ext.get('editinputs').removeCls('visible');
	
	Ext.get('detailoverview').addCls('visible');
    Ext.get('detailoverview').removeCls('hidden');
	 
	
	$(".editInputSpinner" ).spinner("destroy" );
	$("#submitEditedInput").hide();
	$("#editInputBt").show();	
	if (getExperimentInfo("type") == 'Gene Expression'){
		$("#method").html($("#edit_chemistrymethod").val() + ' Chemistry  ');
		updateExperimentInfo("method", $("#edit_chemistrymethod").val());
	}
	$("#equipment").html($("#edit_formatwell").val());
	$("#nomtragets").html($( "#no_of_targets_3" ).val());
	$("#nomsamples").html($( "#no_of_samples_3" ).val());
	$("#nomplicat").html($( "#no_of_replicates_3" ).val());
	
	if(getExperimentInfo("type") == "Mutation Detection"){
		$("#spn_referance_targets_3").show();
		$("#noofreftargets").html($("#no_of_referance_targets_3").val());
		updateExperimentInfo("noofreftargets", Number($("#no_of_referance_targets_3").val()));
	} else {
		$("#spn_referance_targets_3").hide();
	}
	
	updateExperimentInfo("nooftargets", Number($( "#no_of_targets_3" ).val()));
	updateExperimentInfo("noofsamples", Number($( "#no_of_samples_3" ).val()));
	updateExperimentInfo("noofreplicates", Number($( "#no_of_replicates_3" ).val()));
	updateExperimentInfo("noofsubarrays",  Number($( "#no_of_replicates_3" ).val()));
	updateExperimentInfo('equipment', $("#edit_formatwell").val());
	
	//$(".removeEditDrop").addClass("selectDrop");
	//$(".removeEditDrop").addClass("editDrop");
	updateExperimentInfo("isOtherFormat", "NO");
	updateExperimentInfo("isOtherMMFormat", "NO");
	if(currentpno === "111"){
		currentpno = getExperimentInfo("currFmPno");
	}
	var rec = outputList.findRecord('pno', currentpno, 0, false, false, true);
	//var dd = maxTargetList.findRecord('ProductName', rec.get('title')); 
	var isValid = false;
	var ai = 1;
	maxTargetList.each(function(e) {
		//console.log(ai +" == "+e.get('ProductName'));
		ai++;
		//console.log(e.get('Application')+" === "+e.get('ProductName')+" === "+(rec.get('title')) +" === "+ e.get('ProductName').indexOf(rec.get('title')));
		//if( (e.get('Application') == getExperimentInfo("type") )&& (e.get('Species') == getExperimentInfo("species")) && (e.get('ProductName') == rec.get('title') ) ){
		if( (e.get('Application') == "Genotyping" ) && (rec.get('type').indexOf('openarray-fixed') != -1) && ( rec.get('title').indexOf('PGx Panel') == -1 && rec.get('title').indexOf('PGx Express Panel') == -1 ) ){
			if( (e.get('Application') == getExperimentInfo("type") )&& (e.get('Species') == getExperimentInfo("species")) && ( e.get('ProductName').indexOf(rec.get('title')) != -1 ) && (rec.get('format').indexOf(e.get("MaximumTarget")) != -1) ){ 
			// rec.get('format') Format used to check for cards and plates max target
				if( (getExperimentInfo("nooftargets") <= e.get('MaximumTarget')) || (e.get('MaximumTarget') === 0) ){
					isValid = true;
					return;
				}
			}
			
		}else{
			if( ( e.get('Application') == getExperimentInfo("type") ) && ( e.get('Species') == getExperimentInfo("species") ) && ( e.get('ProductName').indexOf(rec.get('title')) != -1 ) ){
				if( (getExperimentInfo("nooftargets") <= e.get('MaximumTarget')) || (e.get('MaximumTarget') === 0) ){
					isValid = true;
					return;
				}
			}
		}
	});
	//console.log('dd :' + dd);
	//updateExperimentInfo("isDetailPage", true);
	var functionName  = rec.get('fnName');
	//var isValid = eval( '('+functionName+'())' );
	//updateExperimentInfo("isDetailPage", false);
	
	if(isValid){
		//console.log(currentpno);
		if(outputList.findExact('pno',currentpno) != -1){
			outputList.removeAt(outputList.findExact('pno',currentpno));
		}
		//updateExperimentInfo("pno", currentpno);
			
		if(rec.get('format').indexOf("Duplex Reactions") != -1){
			eval( '('+functionName+'(true))' );
		}else{
			eval( '('+functionName+'())' );
		}
		
		showDetails(currentpno);
		Ext.get('editinputs').addCls('hidden');
		Ext.get('editinputs').removeCls('visible');
		
		Ext.get('detailoverview').addCls('visible');
		Ext.get('detailoverview').removeCls('hidden');
		 
		
		//$(".editInputSpinner" ).spinner("destroy" );
		$("#submitEditedInput").hide();
		$("#editInputBt").show();	
		$("#errtarget").html("");
	}else{
		//alert("Invalid Target value");
		Ext.get('editinputs').addCls('visible');
		Ext.get('editinputs').removeCls('hidden');
		
		Ext.get('detailoverview').addCls('hidden');
		Ext.get('detailoverview').removeCls('visible');
		$( ".editInputSpinner" ).spinner({ min: 0, max: 10000, step: 1});
		$("#errtarget").html("Invalid Target value");
		$("#submitEditedInput").show();
	}
	
}
function calSelFormatOutput(obj){
	var value = $(obj).attr("val");
	var valArray = value.split("_id_");
	var rec = outputList.findRecord('pno', valArray[1], 0, false, false, true);
	if(outputList.findExact('pno',111) != -1){1
		outputList.removeAt(outputList.findExact('pno',111));
	}
	if(outputList.findExact('pno',valArray[1]) != -1){
		outputList.removeAt(outputList.findExact('pno',valArray[1]));
	}
	updateExperimentInfo("isOtherMMFormat", "NO");
	updateExperimentInfo("isOtherFormat", "YES");
	updateExperimentInfo("selOtherFormatValue", valArray[0]);
	updateExperimentInfo("otherFmPano", valArray[1]);
	var functionName  = rec.get('fnName');
	eval( '('+functionName+'())' );
	outputList.sort('totalcost', 'ASC');
	displayByInstruemnt();
	sortedBy = 1;
	displayChart();
	updateExperimentInfo("isOtherFormat", "YES");
	updateExperimentInfo("selOtherFormatValue", valArray[0]);
	updateExperimentInfo("otherFmPano", 111);
	Ext.get("newsortby").dom.value = "Price"
	
	$("#viewDetailCont").hide();
	$("#overlay").hide();
}
function showEditButton(){

	if (getExperimentInfo("nooftargets") == 0) {
        var nomtragets = 1;
    } else {
        var nomtragets = getExperimentInfo("nooftargets");
    }
    if (getExperimentInfo("noofsamples") == 0) {
        var nomsamples = 1;
    } else {
        var nomsamples = getExperimentInfo("noofsamples");
    }
    if (getExperimentInfo("noofreplicates") == 0) {
        var nomplicat = 1;
    } else {
        var nomplicat = getExperimentInfo("noofreplicates");
    }
	var method = '';
	var chemHtml = "";
	if (getExperimentInfo("type") == 'Gene Expression'){
		method = getExperimentInfo("method");
		if(method === "Fast"){
			chemHtml = "<span class='removeEditDrop selectDrop'><select class='removeEditDrop select editDrop' id='edit_chemistrymethod'><option value='Fast' selected >Fast Chemistry</option><option value='Standard' >Standard Chemistry</option></select></span>";
		}else{
			chemHtml = "<span class='removeEditDrop selectDrop'><select class='removeEditDrop select editDrop' id='edit_chemistrymethod'><option value='Fast' >Fast Chemistry</option><option value='Standard' selected >Standard Chemistry</option></select></span>";
		}
		var anyinstrument = $( "#anyinstrument" ).hasClass( "tbuttonselected" );		
		if(anyinstrument && techboth){
			//addDigitalGenoTyping(false);
		}
		method = getExperimentInfo("method") + " Chemistry &nbsp; ";
	}
	var noofreftargets = getExperimentInfo('noofreftargets');
	var equipment = getExperimentInfo('equipment');
	var format96 = ""
	var format384 = ""
	if(equipment === "96-well"){
		format96 = "selected";
	}else{
		format384 = "selected";
	}
	var openarrayinstrument = getExperimentInfo("openarrayinstrument") + " &nbsp; &nbsp;";
	Ext.get('overview').update(method + openarrayinstrument + nomtragets + " targets &nbsp; &nbsp; " + nomsamples + " samples &nbsp; &nbsp; " + nomplicat + " replicates &nbsp; &nbsp;" +equipment+ " format");
	if(getExperimentInfo("type") == "Mutation Detection"){
		Ext.get('detailoverview').update("<span id='method'>"+method+"</span> " + "<span class='spinCont' id='nomtragets' >"+nomtragets+"</span> " + " targets " +"<span class='spinCont' id='noofreftargets' >"+ noofreftargets +"</span>" + " reference targets "+"<span id='nomsamples' class='spinCont'>"+ nomsamples +"</span> " + " samples  " +"<span id='nomplicat' class='spinCont'>"+ nomplicat +"</span> " + " replicates " + "<span id='equipment' class='spinCont'>"+equipment+"</span> "+ " format <input type='button' id='editInputBt' class='editDet' value='Edit' onclick='editInputsNew();' /> ");
	} else {
		Ext.get('detailoverview').update("<span id='method'>"+method+"</span> " + "<span class='spinCont' id='nomtragets' >"+nomtragets+"</span> " + " targets " +"<span id='nomsamples' class='spinCont'>"+ nomsamples +"</span> " + " samples  " +"<span id='nomplicat' class='spinCont'>"+ nomplicat +"</span> " + " replicates " + "<span id='equipment' class='spinCont'>"+equipment+"</span> "+ " format <input type='button' id='editInputBt' class='editDet' value='Edit' onclick='editInputsNew();' /> ");			
	}

}