function addMITAQCF() {
	/*if(getExperimentInfo('species') == 'Human')
	{
		if(getExperimentInfo('nooftargets') > 377)
		{
			Ext.get('emessage').removeCls('hidden');
			updateContMessage()
			return false;
		}
	}else
	{
		
		console.log("species: " + getExperimentInfo('species') + ", nooftargets: " + getExperimentInfo('nooftargets'));
		if(getExperimentInfo('nooftargets') > 306)
		{
			
			console.log("-----------------------------------------------------------");
			Ext.get('emessage').removeCls('hidden');
			updateContMessage()
			return false;
		}	
	}*/
	if(getExperimentInfo('species') == 'Human')
	{
		if(getExperimentInfo('nooftargets') > 377){
			//Ext.get('warningemessage').removeCls('hidden');
			//updateContMessage();
			warningEMessageArray.push({type:getExperimentInfo("type"), species : getExperimentInfo('species'), targetlimit:377, messageinfopermission:true});
		}else if(getExperimentInfo('nooftargets') > 754){
			Ext.get('emessage').removeCls('hidden');
			updateContMessage()
			return false;
		}
	}else{
		
		console.log("species: " + getExperimentInfo('species') + ", nooftargets: " + getExperimentInfo('nooftargets'));
		if(getExperimentInfo('nooftargets') > 306){
			
			console.log("-----------------------------------------------------------");
			warningEMessageArray.push({type:getExperimentInfo("type"), species : getExperimentInfo('species'), targetlimit:377, messageinfopermission:true});
		}else if(getExperimentInfo('nooftargets') > 641){
			
			console.log("-----------------------------------------------------------");
			Ext.get('emessage').removeCls('hidden');
			updateContMessage()
			return false;
		}	
	}
	Ext.get('emessage').addCls('hidden');
	//var title = "TaqMan<sup>&reg;</sup>&nbsp;Array MicroRNA Card";
	var title = "TaqMan<sup>&reg;</sup>&nbsp;Array MicroRNA Cards";
	var formatObj = findApproximateMirnaRecordFixed(getExperimentInfo('species'), getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'));
	
	var format = formatObj.get('productname');
	if(format.indexOf('Panel') == -1) {
	var partNo = formatObj.get('partnumber');
	var specie = getExperimentInfo('species');
	
	var isPreamp = false;
	if (Ext.get('preampchk').dom.checked || Ext.get('preampchk1').dom.checked) {
		isPreamp = true;
	} else {
		isPreamp = false;
	}
    
	var noofreactions = getExperimentInfo('noofreplicates')
	* getExperimentInfo('noofsamples') * getExperimentInfo('nooftargets');

	
	var cartnoofreactions = formatObj.get('noofitemsinpart');
	var noofsamples = formatObj.get('numberofsamplespercard');
	var reqnoofunits =  Math.ceil(getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples') / cartnoofreactions);
	var min = formatObj.get('min');
	var noofunits = reqnoofunits < min ? min : reqnoofunits;
	//var noofunits = Math.ceil(reqnoofunits);
	
	
	var isMin = (min == 1 ? 1 : (Math.ceil(reqnoofunits) < min ? 0 : 1));

	
	var masterperc = (Ext.get('masterperc').dom.value).split('%')[0];
	var plateperc = (Ext.get('plateperc').dom.value).split('%')[0];

	var mvolume = noofunits * formatObj.get('mastermixneededperunit');
	var mmxObj = findMicrnafixedMMXRecord(mvolume);

	var mastermix = "";
	mastermix = mmxObj.get('productname');
	var mmxPartNumber = mmxObj.get('partnumber');
	var mmxPartVolume = mmxObj.get('volume');
	

	if(format.indexOf("A+B") == -1) {
			var mnoofunits1 = Math.ceil(reqnoofunits * 4 * 400);
			var mnoofunits = Math.ceil(mnoofunits1/mmxPartVolume);

		} else {
			var mnoofunits1 = Math.ceil(reqnoofunits * 4 * 800);
			var mnoofunits = Math.ceil(mnoofunits1/mmxPartVolume);

		}
	
	var assayCostPerUnit = pricelist.findRecord('partnumber', partNo)
	.regions().findRecord('region', region + "-" + currency).get(
	'price');
	var volumeDiscount = 0;
	var costWithVolDisc = noofunits * assayCostPerUnit
			* (1 - (volumeDiscount / 100)); 
	var totalAssayCost = costWithVolDisc * (1 - (plateperc / 100));;
	/* Commented on 02/01/2015
	var masterMixCostPerUnit = mmxObj.get('price');
	*/
	var masterMixCostPerUnit =  pricelist.findRecord('partnumber', mmxPartNumber).regions().findRecord('region', region + "-" + currency).get('price');
	
	var totalMasterMixCost = masterMixCostPerUnit * mnoofunits
			* (1 - (masterperc / 100));
			
	if(specie == "Human") {
		if(format.indexOf("A+B") == -1) {
			
			var newnoofreactions = (377 * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'));
		} else {
			
			var newnoofreactions = (754 * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'));
		}
	} else {
		if(format.indexOf("A+B") == -1) {
			var newnoofreactions = (306 * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'));
		} else {
			var newnoofreactions = (641 * getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'));
		}
	}
	//var newnoofreactions = getExperimentInfo('noofsamples');
	var assayCostPerReaction = totalAssayCost/ newnoofreactions;
	var masterMixCostPerReaction = (totalMasterMixCost) / newnoofreactions;

	var preamprtperc = (Ext.get('preamprtperc').dom.value).split('%')[0];
	
	var rtObj = findMicrnaFixedRTRecord(getExperimentInfo('noofsamples'),
			specie);
	var rtCostPerUnit = pricelist.findRecord('partnumber', rtObj.get('partnumber'))
	.regions().findRecord('region', region + "-" + currency).get(
	'price');
	var rtNoOfReactions = getExperimentInfo('noofsamples');
	var rtNoOfUnits = Math.ceil(rtNoOfReactions / rtObj.get('reactions'));
	var totalRTCost = rtCostPerUnit * rtNoOfUnits * (1 - (preamprtperc / 100));
	var rtCostPerReaction = totalRTCost / newnoofreactions;

	var preAmpObj = findMicrnaFixedPreAmpRecord(
			getExperimentInfo('noofsamples'), specie);
	var preAmpCostPerUnit = pricelist.findRecord('partnumber', preAmpObj.get('partnumber'))
	.regions().findRecord('region', region + "-" + currency).get(
	'price');
	var preAmpNoOfReactions = getExperimentInfo('noofsamples');
	//var preAmpNoOfReactions = newnoofreactions;
	/*
	//Comment accorrding to Lini instruction on DEC 1st 2013 - Below newly modified code for behalf this
	
	var preAmpNoOfUnits = isPreamp ?  Math.ceil(getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples')/40) : 0;
	*/
	var preAmpNoOfUnits = isPreamp ?  Math.ceil(getExperimentInfo('noofsamples')/40) : 0;
	var totalPreAmpCost = preAmpCostPerUnit * preAmpNoOfUnits * (1 - (preamprtperc / 100));
	var preAmpCostPerReaction = totalPreAmpCost /newnoofreactions;
   
	

	
	
	var rtPrimerPoolsObj =  getRTPrimerPools(specie, getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'), (format.indexOf("A+B") != -1 ? "Pool Set v3.0" : "Pool B v3.0"));
	var rtPrimerPools = rtPrimerPoolsObj.get('productname');
	
	var rtPrimerPoolsNoOfUnits = isPreamp ? 0 : Math.ceil(getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples')/rtPrimerPoolsObj.get('reactions'));
    var rtPrimerPoolsPartNumber = rtPrimerPoolsObj.get('partnumber');
    var rtPrimerPoolsPricePerUnit = pricelist.findRecord('partnumber', rtPrimerPoolsPartNumber)
	.regions().findRecord('region', region + "-" + currency).get('price');
    var totalRtPrimerPoolsPriceCost = rtPrimerPoolsPricePerUnit * rtPrimerPoolsNoOfUnits * (1 - (preamprtperc / 100));
    
    var preAmpPrimerPoolsObj =  getPreAmpPrimerPools(specie, getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples'), (format.indexOf("A+B") != -1 ? "Pools Set v3.0" : "Pools B v3.0"));
	var preAmpPrimerPools = preAmpPrimerPoolsObj.get('productname');
	
	/*
	//Comment accorrding to Lini instruction on DEC 1st 2013 - Below newly modified code for behalf this code
	var preAmpPrimerPoolsNoOfUnits = isPreamp ? Math.ceil(getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples')/preAmpPrimerPoolsObj.get('reactions')) : 0;
	*/
	var preAmpPrimerPoolsNoOfUnits = isPreamp ? Math.ceil(getExperimentInfo('noofsamples')/preAmpPrimerPoolsObj.get('reactions')) : 0;
    var preAmpPrimerPoolsPartNumber = preAmpPrimerPoolsObj.get('partnumber');
    var preAmpPrimerPoolsPricePerUnit = pricelist.findRecord('partnumber', preAmpPrimerPoolsPartNumber)
	.regions().findRecord('region', region + "-" + currency).get('price');
    var totalPreAmpPrimerPoolsPriceCost = preAmpPrimerPoolsPricePerUnit * preAmpPrimerPoolsNoOfUnits * (1 - (preamprtperc / 100));
	
    var totalCostPreDisc = costWithVolDisc
	+ (masterMixCostPerUnit * mnoofunits) + totalPreAmpCost
	+ totalRTCost + (preAmpPrimerPoolsPricePerUnit*preAmpPrimerPoolsNoOfUnits) + (rtPrimerPoolsPricePerUnit*rtPrimerPoolsNoOfUnits);
	
	var isMin = reqnoofunits < 1 ? 0 : 1;
    
    var totalCost = totalAssayCost + totalMasterMixCost + totalRTCost
	+ totalPreAmpCost + totalPreAmpPrimerPoolsPriceCost + totalRtPrimerPoolsPriceCost;
   //var totalCostPerReaction = assayCostPerReaction + masterMixCostPerReaction + rtCostPerReaction + preAmpCostPerReaction;
   var totalCostPerReaction = totalCost/newnoofreactions;

	var mmixCostPerSample = totalMasterMixCost/ getExperimentInfo('noofsamples');
	var assayCostPerSample = totalAssayCost / getExperimentInfo('noofsamples');
	var rtCostPerSample = totalRTCost / getExperimentInfo('noofsamples');
	var preAmpCostPerSample = totalPreAmpCost/ getExperimentInfo('noofsamples');
 	var preampprimerpersample = totalPreAmpPrimerPoolsPriceCost / getExperimentInfo('noofsamples');
 	var rtpreampprimerpersample = totalRtPrimerPoolsPriceCost/ getExperimentInfo('noofsamples');
 	var totalCostPerSample = assayCostPerSample + mmixCostPerSample + rtCostPerSample + preAmpCostPerSample + preampprimerpersample+rtpreampprimerpersample;
    
      
    var totalDiscount = 100 - (totalCost * 100 / totalCostPreDisc); 
	var rtProduct = rtObj.get('productname');
	var preAmpProduct = preAmpObj.get('productname');
	var rtPartNumber = rtObj.get('partnumber');
	var preAmpPartNumber = preAmpObj.get('partnumber');

    var preamHours = isPreamp ? 2 : 0;
    var rtHours = 2.5;  // rtHours = 2.5; preamHours =2; cardzHours = noofunits*4*4; noOfHours = Math.ceil(preamHours + rtHours + cardzHours);
    var cardzHours = format.indexOf("A+B") != -1 ? (noofunits*4*4) : (noofunits*2*4);
	var noOfHours = Math.ceil(preamHours + rtHours + cardzHours);
    
	var productUrl = "";
	if(specie == "Human") {
		if(format.indexOf("A+B") == -1) {
			productUrl = "http://products.invitrogen.com/ivgn/product/4444910";
		} else {
			productUrl = "http://products.invitrogen.com/ivgn/product/4444913";
		}
	} else {
		if(format.indexOf("A+B") == -1) {
			productUrl = "http://products.invitrogen.com/ivgn/product/4444899";
		} else {
			productUrl = "http://products.invitrogen.com/ivgn/product/4444909";
		}
	}
	

	outputList.add({
				pno : 17,
				title : title,
				partnumber : partNo,
				format : format.replace(/�/gi, '<sup>&reg;</sup>&nbsp;'),
				rtproduct : rtProduct.replace(/�/gi, '<sup>&reg;</sup>&nbsp;'),
				preampproduct : preAmpProduct.replace(/�/gi,
						'<sup>&reg;</sup>&nbsp;'),
				rtnoofunits : rtNoOfUnits,		
				rtpartnumber : rtPartNumber,
				rtcostperunit : roundNumber(rtCostPerUnit, 2),
				rtcostpersample : roundNumber(rtCostPerSample, 2),
				totalrtcost : roundNumber(totalRTCost, 2),
				preamppartnumber : preAmpPartNumber,
				preampnoofunits : preAmpNoOfUnits,		
				preampcostperunit :roundNumber( preAmpCostPerUnit, 2),
				preampcostpersample : roundNumber(preAmpCostPerSample, 2),
				totalpreampcost : roundNumber(totalPreAmpCost, 2),
				
				noofunits : noofunits,
				noofreactions : newnoofreactions,
				mastermix : mastermix.replace(/�/gi, '<sup>&reg;</sup>&nbsp;'),
				mnoofunits : mnoofunits,
				totalcost : roundNumber(totalCost, 2),
				volumediscount : volumeDiscount,
				mvolumediscount : 0,
				mastermixdisc : masterperc,
				assayscost : roundNumber(assayCostPerUnit, 2),
				assayscostperunit : roundNumber(assayCostPerUnit, 2),
				assayscostwithvoldisc : roundNumber(totalAssayCost, 2),
				mastermixvol : 0,
				mastermixcostperunit : roundNumber(masterMixCostPerUnit, 2),
				mastermixcostwithvoldisc : roundNumber(
						(masterMixCostPerUnit * mnoofunits), 2),
				mastermixcostwithdisc : roundNumber(totalMasterMixCost, 2),
				mastermixcost : roundNumber(
						(masterMixCostPerUnit * mnoofunits), 2),
				noofhours : noOfHours,
				rtcostperreaction : roundNumber(rtCostPerReaction, 2),
				preampcostperreaction : roundNumber(preAmpCostPerReaction, 2),
				assaycostperreaction : roundNumber(assayCostPerReaction, 2),
				mastermixcostperreaction : roundNumber(
						masterMixCostPerReaction, 2),
				optimizationcostperreaction : 0,
				totalcostperreaction : roundNumber(totalCostPerReaction, 2),
				producturl : productUrl,
				totalcostpersample : roundNumber(totalCostPerSample, 2),
				assaycostpersample : roundNumber(assayCostPerSample, 2),
				mmxcostpersample : roundNumber(mmixCostPerSample, 2),
				totalcostpredisc : roundNumber(totalCostPreDisc, 2),
				totaldiscount : roundNumber(totalDiscount, 2),
				mastermixpartnumber : mmxPartNumber,
				rtprimerpools : rtPrimerPools,
				rtprimerpoolsnoofunits : rtPrimerPoolsNoOfUnits,
				rtprimerpoolpartnumber : rtPrimerPoolsPartNumber,
				rtprimerpoolspriceperunit : rtPrimerPoolsPricePerUnit,
				totalrtprimerpoolspricecost : totalRtPrimerPoolsPriceCost,
				preampprimerpools : preAmpPrimerPools,
				preampprimerpoolsnoofunits : preAmpPrimerPoolsNoOfUnits,
				preprimerpoolpartnumber : preAmpPrimerPoolsPartNumber,
				preprimerpoolspriceperunit : preAmpPrimerPoolsPricePerUnit,
				totalpreampprimerpoolspricecost : totalPreAmpPrimerPoolsPriceCost,
				reqnoofunits : reqnoofunits,
				type : 'card-fixed',
				ismin : isMin,
				fnName:'addMITAQCF'
			});
	}
	
	return true;

}

function findApproximateMirnaRecordFixed(species, reactions) {
    species = (species == "Rat" || species == "Mouse") ? "Rodent" : species;
	var recordIndex = 0;
	var count = 0;
	var price = 0;
	mirnaAssay.each(function(record) {
		if (record.get('species') == species && record.get('producttype') == "TaqMan Array Card" && (getExperimentInfo('nooftargets') <= record.get('nooftargets')) ) {
			var noofunits = reactions / record.get('noofitemsinpart');
			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 mirnaAssay.getAt(recordIndex);
}

