function addPgxSNP() {
	outputList.removeAll(true);
	var title = "TaqMan<sup>&reg;</sup>&nbsp;SNP Genotyping Assays";
	var format = "";
	var pgxsnpassaytype = Ext.get("pgxsnpassaytype").dom;
	var pgxsnpassaytypeObjValue = pgxsnpassaytype.options[pgxsnpassaytype.selectedIndex].value;
	if(pgxsnpassaytypeObjValue == "Pre-designed"){
		var subtype = "Made-to-order";
	} else if(pgxsnpassaytypeObjValue == "Custom"){
		var subtype = "Custom";
	}
	var no_of_pgxsamples = Ext.get("no_of_pgxsamples").dom.value;
	var pgxsamplecalctype = Ext.get("pgxsamplecombobox").dom;
    var selectpgxsampleObjValue = pgxsamplecalctype.options[pgxsamplecalctype.selectedIndex].value;
	var no_of_reagentsmonths = Ext.get("no_of_reagentsmonths").dom.value;
	no_of_pgxsamples = no_of_pgxsamples * no_of_reagentsmonths;
	/*
	if(selectpgxsampleObjValue == "days"){
		no_of_pgxsamples = no_of_pgxsamples * no_of_reagentsmonths;
	}else if(selectpgxsampleObjValue == "weeks"){
		no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 7);
	}else if(selectpgxsampleObjValue == "months"){
		no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 31);
	}else if(selectpgxsampleObjValue == "years"){
		no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 365);
	}
	*/
	
	var nooftargets = 0;
	var noofreplicates = Ext.get('pgxsnpreplicates').dom.value;
	var noofreactions =  noofreplicates	* Number(no_of_pgxsamples);
	updateExperimentInfo('no_of_pgxsamples',no_of_pgxsamples)		
	var equipment = null;
	var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
	var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
	
	if(selectpgxsnpopenarrayInstValue === "96-well Standard" || selectpgxsnpopenarrayInstValue === "96-well Fast"){
		equipment = "96-well";
	}else{
		equipment = selectpgxsnpopenarrayInstValue;
	}
	if(selectpgxsnpopenarrayInstValue.indexOf("OpenArray-") != -1){
		nooftargets = 1;
	}else{
		nooftargets = Ext.get("pgxsnpsample").dom.value;
	}

	var species = "Human";
	
	var tubeObj = findOptimumGenoTubeRecord(subtype, species, noofreactions);
	var partNumber = tubeObj.get('partnumber');
	var productName = tubeObj.get('productname');

	var tubenoofreactions = "";
	var wellNum = 96;
	if (equipment == "96-well") {
		tubenoofreactions = tubeObj.get('no of reactions in 96-well tube');
	} else {
		wellNum = 384;
		tubenoofreactions = tubeObj.get('no of reactions in 384-well tube');
	}

	var noofunits = Math.ceil(noofreactions / tubenoofreactions) * nooftargets;
	//var noofunits = Math.ceil(noofreactions) * nooftargets; 
	
	var mvolume = 0;
	if (equipment == '96-well') {
		mvolume = tubeObj.get('mastermix volume perreaction for 96-well')
				* nooftargets
				* noofreplicates
				* Number(no_of_pgxsamples);
	} else if (equipment == '384-well') {
		mvolume = tubeObj.get('mastermix volume perreaction for 384-well')
				* nooftargets
				* noofreplicates
				* Number(no_of_pgxsamples);
	}

	var mmxObj = findGenoMMXRecord(mvolume);

	var mastermix = "";
	mastermix = mmxObj.get('productname');

	var mastermixPartNumber = mmxObj.get('partnumber');
	var mnoofunits = Math.ceil(mvolume / mmxObj.get('volume'));
	var assayCostPerUnit = pricelist.findRecord('partnumber', partNumber).regions()
	.findRecord('region', region + "-" + currency).get('price');
	var volumeDiscount = 0;
	var costWithVolDisc = noofunits * assayCostPerUnit
			* (1 - (volumeDiscount / 100));
	var assayperc = 0;//(Ext.get('assayperc').dom.value).split('%')[0];
	var totalAssayCost = costWithVolDisc * (1 - (assayperc / 100));
	var masterMixCostPerUnit = pricelist.findRecord('partnumber', mastermixPartNumber).regions()
	.findRecord('region', region + "-" + currency).get('price');;
	var masterperc =  0;//(Ext.get('masterperc').dom.value).split('%')[0];
	var totalMasterMixCost = masterMixCostPerUnit * mnoofunits
			* (1 - (masterperc / 100));
	
	var numPlates = Math.ceil(nooftargets
			* noofreplicates
			* Number(no_of_pgxsamples)/wellNum);
	//console.log("Number of plates: " + numPlates);
	var hours = Math.ceil(67/60 * 1.2 * numPlates);

//	var hours = Math.ceil((45 / 60 / wellNum) * nooftargets
//			* noofreplicates
//			* Number(Ext.get("hdpgxsampleval").dom. value));
	var totalCost = totalAssayCost + totalMasterMixCost;

	var assayCostPerReaction = totalAssayCost
			/ (nooftargets
					* noofreplicates * Number(no_of_pgxsamples));
	var masterMixCostPerReaction = (totalMasterMixCost)
			/ (nooftargets
					* noofreplicates * Number(no_of_pgxsamples));
	var optimizationCostPerReaction = 0;
	var totalCostPerReaction = assayCostPerReaction + masterMixCostPerReaction
			+ optimizationCostPerReaction;

	var productUrl = "";
	productUrl = "https://www.invitrogen.com/site/us/en/home/Products-and-Services/Applications/PCR/real-time-pcr/real-time-pcr-assays/snp-genotyping-taqman-assays/single-tube-snp-genotyping.html";
	var mmixCostPerSample = totalMasterMixCost
			/ Number(no_of_pgxsamples);
	var assayCostPerSample = totalAssayCost / Number(no_of_pgxsamples);
	var totalCostPerSample = assayCostPerSample + mmixCostPerSample;

	var totalCostPreDisc = costWithVolDisc
			+ (masterMixCostPerUnit * mnoofunits);
	var totalDiscount = 100 - (totalCost * 100 / totalCostPreDisc);
	
	var formats = productName;
	var formatqnt = formats.replace("Taqman","TaqMan®");
	var format = formatqnt.replace("QuantStudio TM","QuantStudio™");

	outputList.add({
		pno : 100,
		title : title,
		partnumber : partNumber,
		mastermixpartnumber : mastermixPartNumber,
		format :format,
		noofunits : noofunits,
		noofreactions : noofreactions * nooftargets,
		mastermix : mastermix.replace(/�/gi, '<sup>&reg;</sup>&nbsp;'),
		mnoofunits : mnoofunits,
		totalcost : roundNumber(totalCost, 2),
		volumediscount : volumeDiscount,
		mvolumediscount : masterperc,
		assayscost : roundNumber(costWithVolDisc, 2),
		assayscostperunit : roundNumber(assayCostPerUnit, 2),
		assayscostwithvoldisc : roundNumber(totalAssayCost, 2),
		mastermixvol : roundNumber(mvolume, 2),
		mastermixcostperunit : roundNumber(masterMixCostPerUnit, 2),
		mastermixdisc : masterperc,
		mastermixcostwithdisc : roundNumber(totalMasterMixCost, 2),
		mastermixcostpredisc : roundNumber((masterMixCostPerUnit * mnoofunits),
				2),
		mastermixcost : roundNumber(masterMixCostPerUnit * mnoofunits, 2),
		mmxcostpersample : roundNumber(mmixCostPerSample, 2),
		assaycostpersample : roundNumber(assayCostPerSample, 2),
		totalcostpersample : roundNumber(totalCostPerSample, 2),
		totalcostpredisc : roundNumber(totalCostPreDisc, 2),
		totaldiscount : roundNumber(totalDiscount, 2),
		noofhours : hours,
		assaycostperreaction : roundNumber(assayCostPerReaction, 2),
		mastermixcostperreaction : roundNumber(masterMixCostPerReaction, 2),
		optimizationcostperreaction : roundNumber(optimizationCostPerReaction,
				2),
		totalcostperreaction : roundNumber(totalCostPerReaction, 2),
		totalcostpersample : roundNumber(totalCostPerSample, 2),
		producturl : productUrl,
		reqnoofunits : noofunits,
		fnName:'addPgxSNP',
		type : 'tube'
	});
}


function addPgxSNP_new() {
	
	var title = "TaqMan<sup>&reg;</sup>&nbsp;OpenArray<sup>&reg;</sup>&nbsp;Genotyping Plate Custom";
	var no_of_pgxsamples = Ext.get("no_of_pgxsamples").dom.value;
	var pgxsamplecalctype = Ext.get("pgxsamplecombobox").dom;
    var selectpgxsampleObjValue = pgxsamplecalctype.options[pgxsamplecalctype.selectedIndex].value;
	var no_of_reagentsmonths = Ext.get("no_of_reagentsmonths").dom.value;
	
	/*if(selectpgxsampleObjValue == "days"){
		no_of_pgxsamples = no_of_pgxsamples * no_of_reagentsmonths;
	}else if(selectpgxsampleObjValue == "weeks"){
		no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 7);
	}else if(selectpgxsampleObjValue == "months"){
		no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 31);
	}else if(selectpgxsampleObjValue == "years"){
		no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 365);
	}*/
	var noofreplicates = Ext.get('pgxsnpreplicates').dom.value;
	var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
	var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
	if(selectpgxsnpopenarrayInstValue.indexOf("OpenArray") == 0 ){
		var isQuant = false;
	} else {
		var isQuant = true;
	}
	//var isQuant = getExperimentInfo('openarrayinstrument') == "QuantStudio" ? true : false;
	//console.log("isQuant -"+isQuant);
	var nooftargets = Ext.get("pgxcnasample").dom.value;
	var formatObj1 = isQuant ? findApproximateOpenQuantGenoTapRecord(nooftargets) : findApproximateOpenGenoTapRecord(nooftargets);
	var formatObj = findApproximateOpenGenoTapRecord(nooftargets);

	var formats = isQuant ? formatObj1.get('concatenate') : formatObj1.get('productname');
	var formatqnt = formats.replace("TaqMan OpenArray","TaqMan® OpenArray®");
	var format = formatqnt.replace("QuantStudio TM","QuantStudio™");

	var partNo = formatObj1.get('partnumber');
	var noofgenes = nooftargets;
	
	var reqnoofunits = Math.ceil(no_of_pgxsamples * noofreplicates / formatObj.get('no of samples')) / 10;
	var noofunits = reqnoofunits < formatObj.get('min') ? formatObj.get('min')
			: Math.ceil(reqnoofunits);
	//console.log("noofunits - "+noofunits);
	//console.log("noofsamples - "+no_of_pgxsamples+" * noofsubarrays - "+noofreplicates+" / no of samples - "+formatObj.get('no of samples')+" /10 - reqnoofunits - "+reqnoofunits);
	var min = formatObj.get('min');
	var isMin = (min == 1 ? 1 : (Math.ceil(reqnoofunits) < min ? 0 : 1));

	var noofreactions = noofgenes * no_of_pgxsamples * noofreplicates;
	var mvolume = noofreactions * formatObj.get('master mix needed per unit');

	var mmxObj = genoMasterMix.findRecord("productname",
			"TaqMan® OpenArray Genotyping Master Mix");
	var mastermix = mmxObj.get('productname');
	var mmxPartNumber = mmxObj.get('partnumber');
	
	var masterperc = (Ext.get('masterperc').dom.value).split('%')[0];
	var accessperc = (Ext.get('accessoriesperc').dom.value).split('%')[0];
	var volumeDiscount = 0;
	var discObj = tsstable.findRecord('product', formatObj.get('productname'));	
	var discUnits = noofunits > 84 ? 84 : noofunits;

	volumeDiscount = discObj.discounts().findRecord('volume', discUnits, 0,false, false, true).get('value');
	
	//var pricePerUnit = (isQuant ? (formatObj1.get('Pricing or Min Order')/formatObj1.get('min')) : (pricelist.findRecord('partnumber', partNo).regions().findRecord('region', region + "-" + currency).get('price')));
	var pricePerUnit = pricelist.findRecord('partnumber', partNo).regions().findRecord('region', region + "-" + currency).get('price');
	
	var price = pricelist.findRecord('partnumber', partNo).regions().findRecord('region', region + "-" + currency).get('price')* noofunits;
	
	
	var openarrayperc = parseFloat((Ext.get('openarrayperc').dom.value).split('%')[0]);
	var assaysCostWithVolDisc = price - (((volumeDiscount+openarrayperc) / 100) * price);

	
	var openArray384Obj = accessories.findRecord('product', 'OpenArray® 384-well Sample Plates');
	var acc1PartNumber = openArray384Obj.get('partnumber');

	var openArray384WellSamplePlatesUnits = Math.ceil(formatObj
			.get('sampleplates')
			* reqnoofunits) < openArray384Obj.get('min') ? openArray384Obj.get(
					'min') : Math.ceil(formatObj
			.get('open array sample plates per unit')
			* reqnoofunits);
			
		
	var openArray384WellSamplePlatesCost = pricelist.findRecord('partnumber', acc1PartNumber)
	.regions().findRecord('region', region + "-" + currency).get('price')
			* openArray384WellSamplePlatesUnits;
	
	
	var opeArrayAccuObj = accessories.findRecord('product', 'OpenArray® AccuFill® System Tips');
	var acc2PartNumber = opeArrayAccuObj.get('partnumber');

	var openArrayAccuFillSystemTipsUnits = Math.ceil((formatObj.get('open array tips per unit') * reqnoofunits) % 10);

	var openArrayAccuFillSystemTipsCost = pricelist.findRecord('partnumber', acc2PartNumber)
	.regions().findRecord('region', region + "-" + currency).get('price')
			* openArrayAccuFillSystemTipsUnits;
	
	var openArrayAccu10Obj = accessories.findRecord('product', 'OpenArray® AccuFill® System Tips, 10 Pack');
	var acc3PartNumber = openArrayAccu10Obj.get('partnumber');
	
	var openArrayAccuFillSystemTips10Units = Math.floor((formatObj.get('open array tips per unit')
			* reqnoofunits) / 10);
	
	var openArrayAccuFillSystemTips10Cost = pricelist.findRecord('partnumber', acc3PartNumber)
	.regions().findRecord('region', region + "-" + currency).get('price')
			* openArrayAccuFillSystemTips10Units;
	var ntargets = 	nooftargets;
	//console.log("ntargets - "+ntargets);
	if((ntargets > 0) && (ntargets <= 16))
	{	
		
		var masterMixUnits = Math.ceil((reqnoofunits * 0.93750));
	}else if((ntargets > 16) && (ntargets <= 32))
	{
		
		var masterMixUnits = Math.ceil((reqnoofunits * 0.62500));

	}else{
		
		var masterMixUnits = Math.ceil(( reqnoofunits * 0.31250));

	}	
	
	var masterMixCostPerUnit = pricelist.findRecord('partnumber', mmxPartNumber)
	.regions().findRecord('region', region + "-" + currency).get('price');

	var masterMixCost = masterMixCostPerUnit * masterMixUnits;

	var masterMixCostWithDisc = masterMixCostPerUnit * masterMixUnits
			* (1 - (masterperc / 100));
	var openArray384WellSamplePlatesCostWithDisc = openArray384WellSamplePlatesCost * (1 - (accessperc / 100));
	var openArrayAccuFillSystemTips10CostWithDisc = openArrayAccuFillSystemTips10Cost * (1 - (accessperc / 100));
	var openArrayAccuFillSystemTipsCostWithDisc	  = openArrayAccuFillSystemTipsCost * (1 - (accessperc / 100));	
	var accessoriescost = openArrayAccuFillSystemTipsCostWithDisc + openArrayAccuFillSystemTips10CostWithDisc
			+ openArray384WellSamplePlatesCostWithDisc;

	var masterMixCostPerReaction = masterMixCostWithDisc / noofreactions;
	var totalAccessoriescost = accessoriescost;

	var accessoriesCostPerReaction = totalAccessoriescost / noofreactions;

	var assayCostPerReaction = assaysCostWithVolDisc / noofreactions;

	var totalCostPerReaction = masterMixCostPerReaction + assayCostPerReaction
			+ accessoriesCostPerReaction;

	var totalCostPreDisc = accessoriescost + masterMixCost + price;

	// var openarraycost = formatObj.

	var totalCost = totalAccessoriescost + masterMixCostWithDisc
			+ assaysCostWithVolDisc;

	var totalDiscount = 100 - (totalCost * 100 / totalCostPreDisc);

	var assayCostPerSample = assaysCostWithVolDisc
			/ no_of_pgxsamples;
	var acc1CostPerSample = openArray384WellSamplePlatesCostWithDisc
			/ no_of_pgxsamples;
	var acc2CostPerSample = openArrayAccuFillSystemTipsCostWithDisc
			/ no_of_pgxsamples;
	var acc3CostPerSample = openArrayAccuFillSystemTips10CostWithDisc
	/ no_of_pgxsamples;

	var accessoriesCostPerSample = acc1CostPerSample + acc2CostPerSample + acc3CostPerSample;
	var mmixCostPerSample = masterMixCostWithDisc / no_of_pgxsamples;

	var totalCostPerSample = assayCostPerSample + acc1CostPerSample
			+ acc2CostPerSample + acc3CostPerSample + mmixCostPerSample;
	var partNumber = formatObj.get('partnumber');
	var productUrl = producturls.findRecord('partNumber', partNumber).get('productURL');

	
	var noOfHours = 0;
	var oType = getExperimentInfo('openarrayinstrument') == "QuantStudio" ? "GenotypingQS" : "GenotypingNT";
	var tRec = openarrayruntimes.findRecord('type', oType);
	//noOfHours = Math.ceil(Math.ceil((reqnoofunits * 10) / tRec.get('noofplatesperrun')) * tRec.get('totalmin') /60);
	noOfHours = Math.ceil(Math.ceil((reqnoofunits * 10)
			/ tRec.get('noofplatesperrun'))
			* tRec.get('totalmin') / 60);
	
	outputList
			.add({
				pno : 102,
				title : title,
				partnumber : partNo,
				format : format.replace(/�/gi, '<sup>&reg;</sup>&nbsp;'),
				noofunits : noofunits,
				noofreactions : noofreactions,
				mastermix : mastermix
						.replace(/�/gi, '<sup>&reg;</sup>&nbsp;'),
				mnoofunits : masterMixUnits,
				totalcost : roundNumber(totalCost, 2),
				volumediscount : volumeDiscount,
				mvolumediscount : 0,
				mastermixdisc : masterperc,
				accessoriesdisc : accessperc,
				assayscost : price,
				assayscostperunit : pricePerUnit,
				assayscostwithvoldisc : roundNumber(assaysCostWithVolDisc, 2),
				mastermixvol : 0,
				mastermixcostperunit : masterMixCostPerUnit,
				mastermixcostwithvoldisc : masterMixCost,
				mastermixcostwithdisc : roundNumber(masterMixCostWithDisc, 2),
				mastermixcost : masterMixCost,
				noofhours : noOfHours,
				assaycostperreaction : roundNumber(assayCostPerReaction, 2),
				mastermixcostperreaction : roundNumber(
						masterMixCostPerReaction, 2),
				accessoriescostperreaction : roundNumber(
						accessoriesCostPerReaction, 2),
				optimizationcostperreaction : 0,
				totalcostperreaction : roundNumber(totalCostPerReaction, 2),
				producturl : '',
				openarray384wellsampleplatescost : openArray384WellSamplePlatesCost,
				openarrayaccufillsystemtipscost : openArrayAccuFillSystemTipsCost,
				openarrayaccufillsystemtipsunits : openArrayAccuFillSystemTipsUnits,
				openarrayaccufillsystemtips10packunits : openArrayAccuFillSystemTips10Units,
				openarrayaccufillsystemtips10packcost : openArrayAccuFillSystemTips10Cost,
				openarray384wellsampleplatesunits : openArray384WellSamplePlatesUnits,
				mastermixunits : masterMixUnits,
				totalcostpersample : roundNumber(totalCostPerSample, 2),
				accessoriescost : roundNumber(accessoriescost, 2),
				accessoriescostwithdisc : roundNumber(totalAccessoriescost, 2),
				assaycostpersample : roundNumber(assayCostPerSample, 2),
				accessoriescostpersample : roundNumber(
						accessoriesCostPerSample, 2),
				mmxcostpersample : roundNumber(mmixCostPerSample, 2),
				totalcostpredisc : roundNumber(totalCostPreDisc, 2),
				totaldiscount : roundNumber(totalDiscount, 2),
				accessory1partnumber : acc1PartNumber,
				accessory2partnumber : acc2PartNumber,
				accessory3partnumber : acc3PartNumber,
				mastermixpartnumber : mmxPartNumber,
				producturl : productUrl,
				reqnoofunits : reqnoofunits,
				type : 'openarray-custom',
				min : min,
				ismin : isMin
			});

}

function findApproximateOpenGenoTapRecord(value) { 

	var record = null;
	var name = "TaqMan® OpenArray® Genotyping Plate, Custom Format";
	var prevRecord = null;
	
	if ((value > 0) && (value <= 16)) {  
		return genoTypeTubes.findRecord('productname', name + '  16 - Beamer B (Portal)');
	}
	if ((value > 16) && (value <= 32)) { 
		return genoTypeTubes.findRecord('productname', name + '  32 - Beamer B (Portal)');
	}
	
	if ((value > 32) && (value <= 64)) {
		return genoTypeTubes.findRecord('productname', name + '  64 - Beamer B (Portal)');
	}
	
	if ((value > 64) && (value <= 128)) {
		
		return genoTypeTubes.findRecord('productname', name + ' 128 - Beamer B (Portal)');
	}
	
	if ((value > 128) && (value <= 192)) {
		return genoTypeTubes.findRecord('productname', name + ' 192 - Beamer B (Portal)');
	}
	
	if ((value > 192) && (value <= 256)) {
		return genoTypeTubes.findRecord('productname', name + ' 256 - Beamer B (Portal)');
	} else {
		genoTypeTubes.each(function(e) {
			if (e.get('productname').indexOf(name) != -1
					&& e.get('no of targets') == value) {
				record = e;
				return false;
			} else if (e.get('productname').indexOf(name) != -1
					&& e.get('no of targets') > value) {
				if (prevRecord != null && prevRecord >= value)
					record = prevRecord;
				else
					record = e;
				return false;
			}
			prevRecord = e;
		});
		return record;
	}
	
}

function findApproximateOpenQuantGenoTapRecord(value) {

	var record = null;
	var name = "TaqMan® OpenArray® Genotyping Plate, Custom Format";
	var prevRecord = null;
	if ((value > 0) && (value <= 16)) { 
		return quantstudio.findRecord('concatenate', name + ' 16 QuantStudio TM 12K Flex');
	}
	
	if ((value > 16) && (value <= 32)) {  
		return quantstudio.findRecord('concatenate', name + ' 32 QuantStudio TM 12K Flex');
	}
	
	if ((value > 32) && (value <= 64)) { 
		return quantstudio.findRecord('concatenate', name + ' 64 QuantStudio TM 12K Flex');
	}
	
	if ((value > 64) && (value <= 128)) {
		return quantstudio.findRecord('concatenate', name + ' 128 QuantStudio TM 12K Flex');
	}
	
	if ((value > 128) && (value <= 192)) {
		return quantstudio.findRecord('concatenate', name + ' 192 QuantStudio TM 12K Flex');
	}
	
	if ((value > 192) && (value <= 256)) {
		return quantstudio.findRecord('concatenate', name + ' 256 QuantStudio TM 12K Flex');
	} 
	else {
		quantstudio.each(function(e) {
			if (e.get('concatenate').indexOf(name) != -1
					&& e.get('number of Assays or Plate') == value) {
				record = e;
				return false;
			} else if (e.get('concatenate').indexOf(name) != -1
					&& e.get('number of Assays or Plate') > value) {
				if (prevRecord != null && prevRecord >= value)
					record = prevRecord;
				else
					record = e;
				return false;
			}
			else if (e.get('concatenate').indexOf(name) != -1) {
				prevRecord = e;
			}
		});
		return record;
	}
}

function addPGxGenoTubeMadeToOrder() {
	var title = "TaqMan<sup>&reg;</sup>&nbsp;SNP Genotyping Assays";
	var format = "";
	var subtype = "Made-to-order";
	var noofreplicates = Ext.get('pgxsnpreplicates').dom.value;
	var nooftargets = 0;
	var no_of_pgxsamples = Ext.get("no_of_pgxsamples").dom.value;
	var pgxsamplecalctype = Ext.get("pgxsamplecombobox").dom;
    var selectpgxsampleObjValue = pgxsamplecalctype.options[pgxsamplecalctype.selectedIndex].value;
	var no_of_reagentsmonths = Ext.get("no_of_reagentsmonths").dom.value;
	
	/*if(selectpgxsampleObjValue == "days"){
		no_of_pgxsamples = no_of_pgxsamples * no_of_reagentsmonths;
	}else if(selectpgxsampleObjValue == "weeks"){
		no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 7);
	}else if(selectpgxsampleObjValue == "months"){
		no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 31);
	}else if(selectpgxsampleObjValue == "years"){
		no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 365);
	}*/
	
	//var noofreactions = getExperimentInfo('noofreplicates')* getExperimentInfo('noofsamples');
	var noofreactions = noofreplicates	* no_of_pgxsamples;
	
	var pgxopenarraycalctypeobj = Ext.get("pgxcnainstrumentsneedtouse").dom;
	var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
	var equipment = "";
	
	var pgxopenarraycalctypeobj1 = Ext.get("pgxsnpformatneed").dom;
	var selectpgxsnpopenarrayInstValue1 = pgxopenarraycalctypeobj1.options[pgxopenarraycalctypeobj1.selectedIndex].value;
	
	if(selectpgxsnpopenarrayInstValue === "96-well Standard" || selectpgxsnpopenarrayInstValue === "96-well Fast"){
		equipment = "96-well";
	} else if(selectpgxsnpopenarrayInstValue === "384-well"){
		equipment = "384-well";
	} else if( selectpgxsnpopenarrayInstValue === "Same block as SNP analysis" ){
		equipment = selectpgxsnpopenarrayInstValue1;
	}
	//var equipment = getExperimentInfo('equipment');

	var species = "";
	if (getExperimentInfo('species') == "Human") {
		species = "Human";
	} else {
		species = "Non-Human";
	}

	var tubeObj = findOptimumGenoTubeRecord(subtype, species, noofreactions);
	var partNumber = tubeObj.get('partnumber');
	var productName = tubeObj.get('productname');

	var tubenoofreactions = "";
	var wellNum = 96;
	if (equipment == "96-well") {
		tubenoofreactions = tubeObj.get('no of reactions in 96-well tube');
	} else {
		wellNum = 384;
		tubenoofreactions = tubeObj.get('no of reactions in 384-well tube');
	}
	
	if(selectpgxsnpopenarrayInstValue.indexOf("OpenArray-")){
		var nooftargets = 1;
	}else{
		var nooftargets = Ext.get("pgxsnpsample").dom.value;
	}
	
	var noofunits = Math.ceil(noofreactions / tubenoofreactions) * nooftargets;
	var mvolume = 0;
	if (equipment == '96-well') {
		mvolume = tubeObj.get('mastermix volume perreaction for 96-well')
				* nooftargets
				* noofreplicates
				* no_of_pgxsamples;
	} else if (equipment == '384-well') {
		mvolume = tubeObj.get('mastermix volume perreaction for 384-well')
				* nooftargets
				* noofreplicates
				* no_of_pgxsamples;
	}

	var mmxObj = findGenoMMXRecord(mvolume);

	var mastermix = "";
	mastermix = mmxObj.get('productname');

	var mastermixPartNumber = mmxObj.get('partnumber');
	var mnoofunits = Math.ceil(mvolume / mmxObj.get('volume'));
	var assayCostPerUnit = pricelist.findRecord('partnumber', partNumber).regions()
	.findRecord('region', region + "-" + currency).get('price');
	var volumeDiscount = 0;
	var costWithVolDisc = noofunits * assayCostPerUnit
			* (1 - (volumeDiscount / 100));
	var assayperc = (Ext.get('assayperc').dom.value).split('%')[0];
	var totalAssayCost = costWithVolDisc * (1 - (assayperc / 100));
	var masterMixCostPerUnit = pricelist.findRecord('partnumber', mastermixPartNumber).regions()
	.findRecord('region', region + "-" + currency).get('price');;
	var masterperc = (Ext.get('masterperc').dom.value).split('%')[0];
	var totalMasterMixCost = masterMixCostPerUnit * mnoofunits
			* (1 - (masterperc / 100));
	
	var numPlates = Math.ceil(nooftargets
			* noofreplicates
			* no_of_pgxsamples/wellNum);
	//console.log("Number of plates: " + numPlates);
	var hours = Math.ceil(67/60 * 1.2 * numPlates);

//	var hours = Math.ceil((45 / 60 / wellNum) * getExperimentInfo('nooftargets')
//			* getExperimentInfo('noofreplicates')
//			* getExperimentInfo('noofsamples'));
	var totalCost = totalAssayCost + totalMasterMixCost;

	var assayCostPerReaction = totalAssayCost
			/ (nooftargets * noofreplicates * no_of_pgxsamples);
	var masterMixCostPerReaction = (totalMasterMixCost)
			/ (nooftargets * noofreplicates * no_of_pgxsamples);
	var optimizationCostPerReaction = 0;
	var totalCostPerReaction = assayCostPerReaction + masterMixCostPerReaction
			+ optimizationCostPerReaction;

	var productUrl = "";
	productUrl = "https://www.invitrogen.com/site/us/en/home/Products-and-Services/Applications/PCR/real-time-pcr/real-time-pcr-assays/snp-genotyping-taqman-assays/single-tube-snp-genotyping.html";
	var mmixCostPerSample = totalMasterMixCost
			/ no_of_pgxsamples;
	var assayCostPerSample = totalAssayCost / no_of_pgxsamples;
	var totalCostPerSample = assayCostPerSample + mmixCostPerSample;

	var totalCostPreDisc = costWithVolDisc
			+ (masterMixCostPerUnit * mnoofunits);
	var totalDiscount = 100 - (totalCost * 100 / totalCostPreDisc);
	
	var formats = productName;
	var formatqnt = formats.replace("Taqman","TaqMan®");
	var format = formatqnt.replace("QuantStudio TM","QuantStudio™");
	//console.log(partNumber);
	outputList.add({
		pno : 4,
		title : title,
		partnumber : partNumber,
		mastermixpartnumber : mastermixPartNumber,
		format :format,
		noofunits : noofunits,
		noofreactions : noofreactions * nooftargets,
		mastermix : mastermix.replace(/�/gi, '<sup>&reg;</sup>&nbsp;'),
		mnoofunits : mnoofunits,
		totalcost : roundNumber(totalCost, 2),
		volumediscount : volumeDiscount,
		mvolumediscount : masterperc,
		assayscost : roundNumber(costWithVolDisc, 2),
		assayscostperunit : roundNumber(assayCostPerUnit, 2),
		assayscostwithvoldisc : roundNumber(totalAssayCost, 2),
		mastermixvol : roundNumber(mvolume, 2),
		mastermixcostperunit : roundNumber(masterMixCostPerUnit, 2),
		mastermixdisc : masterperc,
		mastermixcostwithdisc : roundNumber(totalMasterMixCost, 2),
		mastermixcostpredisc : roundNumber((masterMixCostPerUnit * mnoofunits),
				2),
		mastermixcost : roundNumber(masterMixCostPerUnit * mnoofunits, 2),
		mmxcostpersample : roundNumber(mmixCostPerSample, 2),
		assaycostpersample : roundNumber(assayCostPerSample, 2),
		totalcostpersample : roundNumber(totalCostPerSample, 2),
		totalcostpredisc : roundNumber(totalCostPreDisc, 2),
		totaldiscount : roundNumber(totalDiscount, 2),
		noofhours : hours,
		assaycostperreaction : roundNumber(assayCostPerReaction, 2),
		mastermixcostperreaction : roundNumber(masterMixCostPerReaction, 2),
		optimizationcostperreaction : roundNumber(optimizationCostPerReaction,
				2),
		totalcostperreaction : roundNumber(totalCostPerReaction, 2),
		totalcostpersample : roundNumber(totalCostPerSample, 2),
		producturl : productUrl,
		reqnoofunits : noofunits,
		fnName:'addPGxGenoTubeMadeToOrder',
		type : 'tube'
	});

}

function addPGxGenoTubeCustom() {
	var title = "Custom TaqMan<sup>&reg;</sup>&nbsp;SNP Genotyping Assays";
	var format = "";
	var subtype = "Custom";
	
	var noofreplicates = Ext.get('pgxsnpreplicates').dom.value;
	//var nooftargets = 0;
	var nooftargets = Ext.get("pgxsnpsample").dom.value;
	var no_of_pgxsamples = Ext.get("no_of_pgxsamples").dom.value;
	var pgxsamplecalctype = Ext.get("pgxsamplecombobox").dom;
    var selectpgxsampleObjValue = pgxsamplecalctype.options[pgxsamplecalctype.selectedIndex].value;
	var no_of_reagentsmonths = Ext.get("no_of_reagentsmonths").dom.value;
	
	if(selectpgxsampleObjValue == "days"){
		no_of_pgxsamples = no_of_pgxsamples * no_of_reagentsmonths;
	}else if(selectpgxsampleObjValue == "weeks"){
		no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 7);
	}else if(selectpgxsampleObjValue == "months"){
		no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 31);
	}else if(selectpgxsampleObjValue == "years"){
		no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 365);
	}
	
	//var noofreactions = getExperimentInfo('noofreplicates')* getExperimentInfo('noofsamples');
	var noofreactions = noofreplicates	* no_of_pgxsamples;
	
	var pgxopenarraycalctypeobj = Ext.get("pgxcnainstrumentsneedtouse").dom;
	var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
	var equipment = "";
	
	var pgxopenarraycalctypeobj1 = Ext.get("pgxsnpformatneed").dom;
	var selectpgxsnpopenarrayInstValue1 = pgxopenarraycalctypeobj1.options[pgxopenarraycalctypeobj1.selectedIndex].value;
	
	if(selectpgxsnpopenarrayInstValue === "96-well Standard" || selectpgxsnpopenarrayInstValue === "96-well Fast"){
		equipment = "96-well";
	} else if(selectpgxsnpopenarrayInstValue === "384-well"){
		equipment = "384-well";
	} else if( selectpgxsnpopenarrayInstValue === "Same block as SNP analysis" ){
		equipment = selectpgxsnpopenarrayInstValue1;
	}
	
	//var noofreactions = noofreplicates * getExperimentInfo('noofsamples');
	
	//var equipment = getExperimentInfo('equipment');
	var species = "";
	if(getExperimentInfo('species') == "Human") {
		species = "Human";
	} else {
		species = "Non-Human";
	}
	var tubeObj = findOptimumGenoTubeRecord(subtype, species, noofreactions);
	var productName = tubeObj.get('productname');
	var partNumber = tubeObj.get('partnumber');
	var tubenoofreactions = "";
	var wellNum = 96;
	if(equipment == "96-well") {
		tubenoofreactions = tubeObj.get('no of reactions in 96-well tube');
	} else {
		wellNum = 384;
		tubenoofreactions = tubeObj.get('no of reactions in 384-well tube');
	}
	
	var noofunits = Math.ceil(noofreactions / tubenoofreactions) * nooftargets;
	//console.log("noofreactions - "+noofreactions+"tubenoofreactions - "+tubenoofreactions+"nooftargets - "+nooftargets);
	var mvolume = 0;
	if (equipment == '96-well') {
		mvolume = tubeObj.get('mastermix volume perreaction for 96-well')
				* nooftargets
				* noofreplicates
				* no_of_pgxsamples;
	} else if (equipment == '384-well') {
		mvolume = tubeObj.get('mastermix volume perreaction for 384-well')
				* nooftargets
				* noofreplicates
				* no_of_pgxsamples;
	}
	
	var mmxObj = findGenoMMXRecord(mvolume);
	
	
	var mastermix = "";
	mastermix = mmxObj.get('productname');
	var mmxPartNumber = mmxObj.get("partnumber");
	var mnoofunits = Math.ceil(mvolume
			/ mmxObj.get('volume'));
	var assayCostPerUnit = pricelist.findRecord('partnumber', partNumber).regions()
	.findRecord('region', region + "-" + currency).get('price');

	var volumeDiscount = 0;
	var costWithVolDisc = noofunits * assayCostPerUnit
			* (1 - (volumeDiscount / 100));
	var assayperc = (Ext.get('assayperc').dom.value).split('%')[0];
	var totalAssayCost = costWithVolDisc * (1 - (assayperc / 100));
	var masterMixCostPerUnit = pricelist.findRecord('partnumber', mmxPartNumber).regions()
	.findRecord('region', region + "-" + currency).get('price');
	var masterperc = (Ext.get('masterperc').dom.value).split('%')[0];
	var totalMasterMixCost = masterMixCostPerUnit * mnoofunits
			* (1 - (masterperc / 100));

	var numPlates = Math.ceil(nooftargets
			* noofreplicates
			* no_of_pgxsamples/wellNum);
	//console.log("Number of plates: " + numPlates);
	var hours = Math.ceil(67/60 * 1.2 * numPlates);
	
//	var hours = Math.ceil((45 / 60 / wellNum) * getExperimentInfo('nooftargets')
//			* getExperimentInfo('noofreplicates')
//			* getExperimentInfo('noofsamples'));
	var totalCost = totalAssayCost + totalMasterMixCost;

	var assayCostPerReaction = totalAssayCost / (nooftargets
			* noofreplicates * no_of_pgxsamples);
	var masterMixCostPerReaction = (totalMasterMixCost) / (nooftargets
					* noofreplicates * no_of_pgxsamples);
    var optimizationCostPerReaction = 0;
    var totalCostPerReaction = assayCostPerReaction + masterMixCostPerReaction + optimizationCostPerReaction;
	
    var productUrl = "";
    productUrl = "https://www.invitrogen.com/site/us/en/home/Products-and-Services/Applications/PCR/real-time-pcr/real-time-pcr-assays/snp-genotyping-taqman-assays/custom-snp-assays.html";
    var mmixCostPerSample = totalMasterMixCost / no_of_pgxsamples;
	var assayCostPerSample = totalAssayCost / no_of_pgxsamples;
	var totalCostPerSample = assayCostPerSample + mmixCostPerSample;
	
	var totalCostPreDisc = costWithVolDisc + (masterMixCostPerUnit * mnoofunits);
	var totalDiscount = 100 - (totalCost*100/totalCostPreDisc);

	var formats = productName;
	var formatqnt = formats.replace("TaqMan","TaqMan®");
	var format = formatqnt.replace("QuantStudio TM","QuantStudio™");
    //console.log(partNumber);
	outputList.add({
		pno : 2,
		title : title,
		partnumber : partNumber,
		mastermixpartnumber : mmxPartNumber,
		format : format,
		noofunits : noofunits,
		noofreactions : noofreactions * nooftargets,
		mastermix : mastermix.replace(/�/gi, '<sup>&reg;</sup>&nbsp;'),
		mnoofunits : mnoofunits,
		totalcost : roundNumber(totalCost, 2),
		volumediscount : volumeDiscount,
		mvolumediscount : masterperc,
		assayscost : roundNumber(costWithVolDisc, 2),
		assayscostperunit : roundNumber(assayCostPerUnit, 2),
		assayscostwithvoldisc : roundNumber(totalAssayCost, 2),
		mastermixvol : roundNumber(mvolume, 2),
		mastermixcostperunit : roundNumber(masterMixCostPerUnit, 2),
		mastermixdisc : masterperc,
		mastermixcostwithdisc: roundNumber(totalMasterMixCost, 2),
		mastermixcostpredisc : roundNumber((masterMixCostPerUnit * mnoofunits), 2),
		mastermixcost : roundNumber(masterMixCostPerUnit * mnoofunits, 2),
		mmxcostpersample : roundNumber(mmixCostPerSample,2),
		assaycostpersample : roundNumber(assayCostPerSample,2),
		totalcostpersample : roundNumber(totalCostPerSample,2),
		totalcostpredisc : roundNumber(totalCostPreDisc,2),
		totaldiscount : roundNumber(totalDiscount,2),
		noofhours : hours,
		assaycostperreaction : roundNumber(assayCostPerReaction, 2),
		mastermixcostperreaction : roundNumber(masterMixCostPerReaction, 2),
		optimizationcostperreaction : roundNumber(optimizationCostPerReaction,
				2),
		totalcostperreaction : roundNumber(totalCostPerReaction, 2),
		totalcostpersample: roundNumber(totalCostPerSample, 2),
		producturl : productUrl,
		reqnoofunits : noofunits,
		fnName:'addPGxGenoTubeCustom',
		type: 'tube'
	});

}