var tapf = {
		partnumber: "multiple",
		product: "Gene Specific 96-Well Array Plates",
		price: 275,
		genes : 96,
		reactions: 96,
		samples: 2,
		min: 1,
		totalreactions: 96,
		species: "Any"
};


function addTAPF(){
	
	//Added on 31/10/2014 - By Magesh.
	updateExperimentInfo("isPlate", "None");
	
	var title = "TaqMan<sup>&reg;</sup>&nbsp;Array Plates - Fixed Panels";
	var productUrl = "";
	productUrl = "http://products.invitrogen.com/ivgn/en/US/adirect/invitrogen?cmd=catDisplayStyle&catKey=600863&filterDispName=Real-Time+PCR+Primers%2C+Probes+%26amp%3B+Arrays&filterType=1&OP=filter&filter=ft_1701%2Ff_2006057*&_bcs_=H4sIAAAAAAAAAM2P22rDMAxAv8YvMylOPLL0MUtpGYNRml2ejaM2AscxttuSv5%2FSG2Mrg74VjGTL%0AlnVOkjJRLH3fbHUMnGU5r8HvUEP4p97G6JgsWTantd%2FvJ2h3GH2%2FATvRfUfFgBEobQMFsBTavhsL%0A5x8TZZvk8mM2L50zqFXE3oZJGztDU1gmxyWK6LcwnsWToJSKlBqmeSbSBzrWBhsYAVVHTM%2B8atHx%0A0ns1%2FCF1p%2BG%2FcWVZCLrG3caecT9qCqpBDzqOV5cGJue6a5icvXwu3gh4hsEZNVQqwqb3A3FQ8RUG%0AenFA%2FOmxViZcF6GcC1E8HoxWoEzyjh3wZbW6D5Uj3I0up00uR6kFWOC1A41r1HyaJ19gzFGOLw2N%0AvAfFXF5T%2FAb3lh4ZIwMAAA%3D%3D";
	//var format = "Multiple";
	var format = title;
	var noofreplicates = 1;
	var noofsamples = tapf.samples;
	var formatObj = findPlateType(getExperimentInfo('nooftargets'));
	if ((getExperimentInfo('nooftargets') > 96) || (formatObj == null)) return false;
	
	var partNumber = formatObj.get('partnumber');
	
	var noofgenes = formatObj.get('formatno');
	var reqnoofunits = (getExperimentInfo('noofsamples') * getExperimentInfo('noofreplicates'))/formatObj.get('numberofsamples');
	
	var noofunits = reqnoofunits < formatObj.get('min') ? formatObj.get('min')
			: Math.ceil(reqnoofunits);
	var min = formatObj.get('min');
	var isMin = 1;
	
	var noofreactions = noofunits * formatObj.get('numberofreactions');
	var mvolume = 0;
	if (getExperimentInfo('method') == 'Fast') {
		mvolume = ((platesMMixPerRxn * noofreactions) / 1000) * 0.5;
	} else {
		mvolume = (platesMMixPerRxn * noofreactions) / 1000;
	}
	var mastermixObj = findOptimumGeneMicroMMXTubeRecord(mvolume);
	var mastermix = mastermixObj.get('product');
	var mastermixPartNumber = mastermixObj.get('partnumber');

	var mnoofunits = Math.ceil(mvolume / mastermixObj.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 plateperc = (Ext.get('plateperc').dom.value).split('%')[0];
	var totalAssayCost = costWithVolDisc * (1 - (plateperc / 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 hours = 1;
	if (getExperimentInfo('method') == 'Fast') {
		hours = Math.ceil((40 * 1.2 / 60) * Math.ceil(reqnoofunits));
	} else {
		hours = Math.ceil((75 * 1.2 / 60) * Math.ceil(reqnoofunits));
	}

	var totalCost = totalAssayCost + totalMasterMixCost;

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

	
	

	var mmixCostPerSample = totalMasterMixCost
			/ getExperimentInfo('noofsamples');
	var assayCostPerSample = totalAssayCost / getExperimentInfo('noofsamples');
	var totalCostPerSample = assayCostPerSample + mmixCostPerSample;

	var totalCostPreDisc = costWithVolDisc
			+ (masterMixCostPerUnit * mnoofunits);
	var totalDiscount = 100 - (totalCost * 100 / totalCostPreDisc);
	
	var partNumber = "Multiple";
	
	outputList.add({
		pno : 46,
		title : title,
		partnumber : partNumber,
		format : format.replace(/�/gi, '<sup>&reg;</sup>&nbsp;'),
		noofunits : noofunits,
		noofreactions : noofreactions * getExperimentInfo('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,
		mastermixpartnumber : mastermixPartNumber,
		assaycostperreaction : roundNumber(assayCostPerReaction, 2),
		mastermixcostperreaction : roundNumber(masterMixCostPerReaction, 2),
		optimizationcostperreaction : roundNumber(optimizationCostPerReaction,
				2),
		totalcostperreaction : roundNumber(totalCostPerReaction, 2),
		totalcostpersample : roundNumber(totalCostPerSample, 2),
		producturl : productUrl,
		reqnoofunits : reqnoofunits,
		type : 'plate-fixed',
		min : 1,
		fnName:'addTAPF',
		ismin : isMin
	});


}

function findPlateType(value) {
	var record = null;
	var specie = getExperimentInfo('species');
	var method = getExperimentInfo('method')
	//console.log("targets:" + value + " " + specie + " " + method);
	taqManArrayPlatesFixed.each(function(e) {
		if (e.get('Species') == specie
			&& e.get('Type') == method
			&& e.get('formatno') >= value)
						{
			//console.log(e.get('Species') + " " + e.get('formatno'));
			record = e;
			return false;
		}
	});
	return record;
}