// Latest Q_81
var discchgid = 0;
var pnos = 0
var currentpno = 0;
var currentVolumeDiscount = 0;
var minqtydetailsinfo = [];
var expType='';
var PartNo='';
//var addDisc = 0;
var ismin = 0;
var min =0;
var globalFormatName = '';

function isGeneExpFixed(pno) {
	if (pno == 46 || pno == 13 || pno == 12) return false;
	else return false;
}

function showDetails(pno, sortBy) {
	//if (isGeneExpFixed(pno)) return;
	updateExperimentInfo("isDigitalPCR", "false");
	pnos = pno;
	currentpno = pno;
	Ext.get('sybrdetails').removeCls('visible');
	Ext.get('sybrdetails').addCls('hidden');
	Ext.get('sybrtotalcost_div').removeCls('visible');
	Ext.get('sybrtotalcost_div').addCls('hidden');
	
	$("#editInputBt").show();
	
	//Ext.get('selProductname').update("hai");
	var isCSPCalc = false;
	if(getExperimentInfo("isCustomPlatingCalc")){
		isCSPCalc = true;
	} else {
		isCSPCalc = false;
	}
	
	var isCPSoamiRNA = getExperimentInfo("isCPSoamiRNA");
	
	enableDetailPage = true;
	managetab("details", "steptwo", "tabbar");
	
	detailspageinfo.removeAll();
	minqtydetailsinfo= [];
	if (sortBy == 0) {
		outputList.sort('noofhours', 'ASC');
	} else {
		outputList.sort('totalcost', 'ASC');
	}
	var maillist = "";
	var rowTitle = "";
	
	var rowTitleLink = "";
	
	var rec = outputList.findRecord('pno', pno, 0, false, false, true);
	Ext.get('selProductname').update(rec.get('title'));
	globalFormatName = rec.get('format');
	rowTitle = rec.get('format');
	ismin = rec.get('ismin');
	min = rec.get('min');
	//Ext.get('selProductname').update('for '+rec.get('title'));
	currentVolumeDiscount = parseFloat(rec.get('volumediscount'));
	maillist += rec.get('title') + " - ";
	// clearTable('detailstable');
	clearTable('productdetailstable');
	var count = 0;
	
	Ext.get('totalcost').update(convertCurrency((rec.get('totalcost')), region + "-" + currency));
	if(rowTitle.indexOf('Digital PCR') == -1){
		Ext.get('costperreaction').update(convertCurrency((rec.get('totalcostperreaction')), region + "-" + currency));
		Ext.get('costpersample').update(convertCurrency((rec.get('totalcostpersample')), region + "-" + currency));
		Ext.get('priceperrxn').update('Price per rxn')
		Ext.get('pricepersample').update('Price per sample')
	} else {
		updateExperimentInfo("technology", "DigitalPCR");
		Ext.get('priceperrxn').update('Price per Answer *')
		Ext.get('pricepersample').update('Price per sample *')
		Ext.get('costperreaction').update(convertCurrency((rec.get('totalcostperreaction')), region + "-" + currency)+'*');
		Ext.get('costpersample').update(convertCurrency((rec.get('totalcostpersample')), region + "-" + currency)+'*');
	}
	Ext.get('totaltime').update(rec.get('noofhours') + " hours");
	
	if( rowTitle.indexOf('Digital PCR') == -1){ 
		Ext.get('digitalmsg').update("");
		Ext.get('priceperans').update("Price per reaction");
		Ext.get('snpspan').update("");
	} else {
		if (getExperimentInfo("type") == 'Mutation Detection') {
			Ext.get('snpspan').update("* SNP Genotyping Assays are recommended for Mutation Detection on QuantStudio 3D Digital PCR platform");
		} else {
			Ext.get('snpspan').update("");
		}
		Ext.get('priceperans').update("Price per Answer");
		Ext.get('digitalmsg').update("* Indicates the cost for exact quantity used.");
	}
	var plateperc = (Ext.get('plateperc').dom.value).split('%')[0];
	var assayperc = (Ext.get('assayperc').dom.value).split('%')[0];
	var masterperc = (Ext.get('masterperc').dom.value).split('%')[0];
	var accessoriesperc = (Ext.get('accessoriesperc').dom.value).split('%')[0];
	var openarrayperc = (Ext.get('openarrayperc').dom.value).split('%')[0];
	var preamprtperc = (Ext.get('preamprtperc').dom.value).split('%')[0];
	cellValues = new Array(9); //Madhu asked to remove type column on 09/01/2015
	if( !isCSPCalc ){
		cellValues = new Array(10);
		$('#voldisc').show();
		$('#totaldisc').show();
		$('#priceperrxn').show();
		$('#pricepersample').show();
		$('#voldischeader').show();
		$('#totdischeader').show();
	} else if( isCPSoamiRNA ){
		cellValues = new Array(7);
		$('#voldischeader').show();
		$('#voldisc').hide();
		$('#totaldisc').hide();
		$('#priceperrxn').hide();
		$('#pricepersample').hide();
		$('#totdischeader').hide();
	} else {
		cellValues = new Array(6);
		$('#voldisc').hide();
		$('#totaldisc').hide();
		$('#priceperrxn').hide();
		$('#pricepersample').hide();
		$('#voldischeader').hide();
		$('#totdischeader').hide();
	}
	
	
	//console.log("assayscostperunit: " + pno + " + " + rec.get('assayscostperunit'));
	
	count = 0;
	
	expType = rowTitle;
	rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
	var tType = rec.get('type'); 
	var buttonName ='';
	var viewOtherFormatBtn = "";
	var isDrugMetabolism = false;
	if( !isCSPCalc ){
		isDrugMetabolism = false;
		if( (getExperimentInfo("type") != "Mutation Detection") && (rowTitle.indexOf('OpenArray') == -1) ){	
			if ( (rowTitle.indexOf('Card') != -1) || (rowTitle.indexOf('Plate') != -1) ){
				buttonName = "View Other Formats";
			} else if ( rowTitle.indexOf('DME') != -1 ){
				isDrugMetabolism = true;
			} else {
				buttonName = "View other sizes and product flavours";
			}
			if(!isDrugMetabolism && (rowTitle.indexOf('Advanced') == -1) ){
				var viewOtherFormatBtn = '<span class="viewParnt" id=""><div id="viewParntDiv" class="viewParntDivDetPge"></div><button class="viewDet" value="viewDetailCont_viewParntDiv_'+pno+'" onclick="ViewDetails(\''+rowTitle+'\',this, \''+tType+'\'); return false;">'+buttonName+'</button></span>&nbsp;';
			}
		}
	}
	
	/*
	if ( (rowTitle.indexOf('Card') != -1) || (rowTitle.indexOf('Plate') != -1) ) {
		Ext.get('selProductname').update('for '+rowTitle + viewOtherFormatBtn);
	}else{
		Ext.get('selProductname').update('for '+rowTitle );
	}*/
	
	if(rec.get('title').indexOf('Fast') != -1){
		Ext.get('selProductname').update(rowTitle+' - Fast' );
	} else {
		Ext.get('selProductname').update(rowTitle );
	}
	if ( ((rowTitle.indexOf('Card') != -1) || (rowTitle.indexOf('Plate') != -1) || tType == 'tube' )&& (tType.indexOf('fixed') == -1)  ) {
		cellValues[count++] = rowTitleLink + viewOtherFormatBtn;
	}else{
		cellValues[count++] = rowTitleLink;
	}
	
	//Madhu asked to remove type column on 09/01/2015
	/*if(rowTitle.indexOf('Chips') == -1){
		cellValues[count++] = (rec.get('type').indexOf('tube') != -1 ? 'Assay' : 'Array');
	}else {
		cellValues[count++] = (rowTitle.indexOf('Chips') != -1 ? 'QS 3D Chips' : rec.get('type'));
	}*/
	
	//console.log("Chips -"+rec.get('noofreactions'));
	cellValues[count++] = rec.get('noofreactions');
	cellValues[count++] = rec.get('partnumber');
	PartNo = rec.get('partnumber');
	//cellValues[count++] = rec.get('noofunits');

	//cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner' partno='"+PartNo+"' id='Q_0' name='Q_0' value ='"+ rec.get('noofunits')+"' >";
	cellValues[count++] = "<input class = 'EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' partno='"+PartNo+"' id='Q_0' name='Q_0' value ='"+ rec.get('noofunits')+"' >";

	cellValues[count++] = convertCurrency((rec.get('assayscostperunit')), region + "-" + currency);
	
		if( !isCSPCalc || isCPSoamiRNA){
			if(isCPSoamiRNA){
				var seldisCountObj = OpenArrayDisVal.findRecord("product", rowTitle);
			} else {
				var seldisCountObj = OpenArrayDisVal.findRecord("partnumber", PartNo);
			}
			if( seldisCountObj != null){
				var discountObj = seldisCountObj.discounts();
				cellValues[count++] = '<div class="prodConfigViewFormat quantValParnt" id="popQuantVal" style="display: none;z-index:999999999999"></div><span id='+PartNo+' >'+currentVolumeDiscount+'</span><img src="images/info.png" alt="Volume Discount" onmouseover="DisplayVolDiscount(this,'+PartNo+',\''+rowTitle+'\');"/>';		
			} else {
				cellValues[count++] = "<span id='"+PartNo+"'>"+currentVolumeDiscount+"</span>";
			}
		}
	
	var discHtml = "<div><a href='#' onclick='showEditDiscPopup(0); return false;' class='EditTotalDiscount'>Edit</a></div>";
	var addDisc = 0;
	
	if (rec.get('type').indexOf('openarray') != -1) {
		addDisc = openarrayperc; 
	} else if (rec.get('type').indexOf('card') != -1 || rec.get('type').indexOf('plate') != -1) {
		addDisc = plateperc; 
	} else if(rec.get('type') != "chips") {
		addDisc = assayperc; 
	}
	
	
	var totdisc1 = (parseFloat(rec.get('volumediscount')) + parseFloat(addDisc));
	/*if( region == "EMEA" || region == "emea"){
		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' id='0' name='0' value ='0' partno='"+PartNo+"' >";		
	} else {*/
		if( !isCSPCalc ){
			cellValues[count++] = '<input class = "input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner" onkeyup="updatePriceChange(this);" id="0" name="0" value ='+ totdisc1+' partno='+PartNo+' >';
		}
	//}
	//cellValues[count++] = (parseFloat(rec.get('volumediscount')) + parseFloat(addDisc)) + discHtml;
	/*if( rec.get('isMultiplex') ){
		cellValues[count++] = convertCurrency((rec.get('assayscostwithvoldisc')/rec.get('noofreactions')), region + "-" + currency);
	} else{*/
	if( !isCSPCalc ){
		cellValues[count++] = convertCurrency((rec.get('assaycostperreaction')), region + "-" + currency);
	}
	//}
	if( !isCSPCalc ){
		cellValues[count++] = convertCurrency((rec.get('assaycostpersample')), region + "-" + currency);
	}
	cellValues[count++] = convertCurrency(rec.get('assayscostwithvoldisc'), region + "-" + currency);
	detailspageinfo.add({
		id: 0,
		product: rowTitle,
		//type: cellValues[1],
		type: rec.get('type'),
		noofreactions: cellValues[1],
		partnumber: cellValues[2],
		quantity:  rec.get('noofunits'),
		unitprice: rec.get('assayscostperunit'),
		volumediscount2: rec.get('volumediscount'),		
		discount: rec.get('volumediscount') + parseFloat(addDisc),
		priceperreaction: rec.get('assaycostperreaction'),
		pricepersample: rec.get('assaycostpersample'),
		netprice: rec.get('assayscostwithvoldisc'),
		volumediscount: rec.get('volumediscount'),
		ismin:ismin,
		min:min,
		fnName:rec.get('fnName'),
		formattype:rec.get('type')
	});
	addRow('productdetailstable', cellValues, false);
	
	if (isNumber(rec.get('refassayqty')) && rec.get('refassayqty') > 0) {		
		count = 0;
		rowTitle = rec.get('refassayname');
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('refassaypartnumber'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('refassaypartnumber'));
		cellValues[count++] = rowTitleLink;
		//cellValues[count++] = (rec.get('type').indexOf('tube') != -1 ? 'Assay' : 'Array');
		var QS3D = $( "#QS3D" ).hasClass( "tbuttonselected" );
		
		//Madhu asked to remove type column on 09/01/2015
		/*if(QS3D){
			cellValues[count++] = 'Assay';			
		} else {
			cellValues[count++] = (rec.get('type').indexOf('tube') != -1 ? 'Assay' : 'Array');
		}*/
		if (getExperimentInfo("type") == 'Mutation Detection') {
			cellValues[count++] = rec.get('refunitsreactions');
		} else {
			cellValues[count++] = rec.get('noofreactions');
		}
		cellValues[count++] = rec.get('refassaypartnumber');
		//cellValues[count++] = rec.get('refassayqty');
		
		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_15' name='Q_15' value ='"+ rec.get('refassayqty')+"' >";

		cellValues[count++] = convertCurrency((rec.get('refassaypercost')), region + "-" + currency);
		cellValues[count++] = VolumeDiscounts;
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(15); return false;' class='EditTotalDiscount'>Edit</a></div>";
		var addDisc = 0;
		if (rec.get('type').indexOf('openarray') != -1) {
			addDisc = openarrayperc;
		} else if (rec.get('type').indexOf('card') != -1 || rec.get('type').indexOf('plate') != -1) {
			addDisc = plateperc;
		} else {
			addDisc = assayperc;
		}
		var totdisc15 = (parseFloat(rec.get('volumediscount')) + parseFloat(addDisc));
		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='15' name='15' value ='"+ totdisc15 +"' >";
		//cellValues[count++] = (parseFloat(rec.get('volumediscount')) + parseFloat(addDisc)) + discHtml;
		cellValues[count++] = convertCurrency(parseFloat(rec.get('refassayperreaction')), region + "-" + currency);
		cellValues[count++] = convertCurrency(parseFloat(rec.get('refassaycostpersample')), region + "-" + currency);
		cellValues[count++] = convertCurrency(rec.get('refassaycost'), region + "-" + currency);
		detailspageinfo.add({
			id: 15,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity:  rec.get('refassayqty'),
			unitprice: rec.get('refassaypercost'),
			volumediscount2: VolumeDiscounts,
			discount: rec.get('volumediscount') + parseFloat(addDisc),
			priceperreaction: rec.get('refassayperreaction'),
			pricepersample: rec.get('refassaycostpersample'),
			netprice: rec.get('refassaycost'),
			refassayreaction: rec.get('refassayreaction')
		});
		addRow('productdetailstable', cellValues, false);
	}
	
	var VolumeDiscounts = 0;	
	if (isNumber(rec.get('mnoofunits')) && rec.get('mnoofunits') > 0) {		
		count = 0;
		rowTitle = rec.get('mastermix');
		
			rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('mastermixpartnumber'), rec.get('producturl')));
			VolumeDiscounts = getVolumeDiscount(rec.get('mastermixpartnumber'));
			//if ( ( (globalFormatName.indexOf('Card') != -1) || (globalFormatName.indexOf('Plate') != -1) )&& (getExperimentInfo("type") == "Gene Expression") ) {
			
			var mmButtonName ='';
			if(tType.indexOf('tube') != -1){
				mmButtonName = 'View other sizes and product flavours';
			} else {
				mmButtonName = 'View More Options';
			}
				
			if ( ( (globalFormatName.indexOf('Card') != -1) || (globalFormatName.indexOf('Plate') != -1) || (tType.indexOf('tube') != -1)  ) && ((globalFormatName.indexOf('OpenArray') == -1) && (tType.indexOf('fixed') == -1)) && !isCSPCalc ) {
				var viewOtherMMBtn = '<span class="viewParnt" id=""><div id="viewMMParntDiv" class="viewParntDivDetPge viewParntMMPge"></div><button class="viewDet" onclick="ViewOtherMMDetails(\''+globalFormatName+'\',\''+rowTitle+'\',\''+pno+'\'); return false;">'+mmButtonName+'</button></span>&nbsp;';
				cellValues[count++] = rowTitleLink + viewOtherMMBtn;
			} else {
				cellValues[count++] = rowTitleLink;
			}
			//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Master Mix';
			//console.log("MM 1.5 -"+rec.get('noofreactions'));
			if (getExperimentInfo("type") == 'Mutation Detection') {
				cellValues[count++] = rec.get('totalrefreactions');
			} else {
				cellValues[count++] = rec.get('noofreactions');
			}
			cellValues[count++] = rec.get('mastermixpartnumber');
			//cellValues[count++] = rec.get('mnoofunits');

			cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_9' name='Q_9' value ='"+ rec.get('mnoofunits')+"' >";

			cellValues[count++] = convertCurrency(rec.get('mastermixcostperunit'), region + "-" + currency);	
			if( !isCSPCalc || isCPSoamiRNA ){			
				cellValues[count++] = VolumeDiscounts;
			}
			var discHtml = "<div><a href='#' onclick='showEditDiscPopup(9); return false;' class='EditTotalDiscount'>Edit</a></div>";
			if( !isCSPCalc ){
				cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='9' name='9' value ='"+ rec.get('mastermixdisc') +"' >";
			}
			//cellValues[count++] = rec.get('mastermixdisc') + discHtml;
			/*if (getExperimentInfo("type") == 'Mutation Detection') { console.log(rec.get('mastermixcostperreaction'));
				cellValues[count++] = convertCurrency(parseFloat(rec.get('mastermixcostperreaction')).toFixed(2), region + "-" + currency);
			} else {*/
				
				if(rec.get('pno') == 1 || rec.get('pno') == 2 || rec.get('pno') == 5 || rec.get('pno') == 6 || rec.get('pno') == 7 || rec.get('pno') == 8){		
					if( !isCSPCalc ){
						cellValues[count++] = convertCurrency(parseFloat((rec.get('mastermixcost')) / (rec.get('noofreactions'))).toFixed(2), region + "-" + currency);					
						cellValues[count++] = convertCurrency((rec.get('mmxcostpersample')), region + "-" + currency);
					}
					var priceperreaction = rec.get('mastermixcost') / rec.get('noofreactions');
					var pricepersample = rec.get('mmxcostpersample') ;
				} else if(rowTitle.indexOf('Digital PCR Master Mix (5mL)') == -1){					
					if(rec.get('mnoofunits1') > 0){
						if( !isCSPCalc ){
							var priceperreaction = rec.get('mastermixcostperreaction1') ;
							cellValues[count++] = convertCurrency(priceperreaction, region + "-" + currency);
							var pricepersample = rec.get('mmxcostpersample1');
							cellValues[count++] = convertCurrency(pricepersample, region + "-" + currency);
						}
						var displaypriceperrxn = false;
					} else {
						if( !isCSPCalc ){
							cellValues[count++] = convertCurrency((rec.get('mastermixcostperreaction')), region + "-" + currency);
							cellValues[count++] = convertCurrency((rec.get('mmxcostpersample')), region + "-" + currency);
						}
						var displaypriceperrxn = true;
					}
					
					var priceperreaction = rec.get('mastermixcostperreaction');
					var pricepersample = rec.get('mmxcostpersample')
				}  else {
					if( !isCSPCalc ){
						cellValues[count++] = convertCurrency(parseFloat((rec.get('mastermixcost')) / (rec.get('noofreactions'))).toFixed(2), region + "-" + currency);
						cellValues[count++] = convertCurrency((rec.get('mmxcostpersample')), region + "-" + currency);
					}
					var priceperreaction = rec.get('mastermixcost') / rec.get('noofreactions');
					var pricepersample = rec.get('mmxcostpersample') ;
				}
			//}
			
			cellValues[count++] = convertCurrency(rec.get('mastermixcostwithdisc'), region + "-" + currency);
			
			detailspageinfo.add({
				id: 9,
				product: rowTitle,
				//type: cellValues[1],
				type: rec.get('type'),
				noofreactions: cellValues[1],
				partnumber: cellValues[2],
				quantity: rec.get('mnoofunits'),
				unitprice: rec.get('mastermixcostperunit'),
				volumediscount2: VolumeDiscounts,
				discount: rec.get('mastermixdisc'),
				priceperreaction: priceperreaction,
				pricepersample: pricepersample,
				netprice: rec.get('mastermixcostwithdisc'),
				volumediscount: 0,
				displaypriceperrxn: displaypriceperrxn,
				mastermixcostwithdisc1:rec.get('mastermixcostwithdisc1'),
				formattype: tType
				
			});
			addRow('productdetailstable', cellValues, false);
		//}
	}
	
	if (isNumber(rec.get('mnoofunits1')) && rec.get('mnoofunits1') > 0) { 
		var displaypriceperrxn = true;
		count = 0;
		rowTitle = rec.get('mastermix1');
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('mastermixpartnumber1'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('mastermixpartnumber1'));
		cellValues[count++] = rowTitleLink;
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Master Mix';
		//console.log("MM 5 -"+rec.get('noofreactions'));
		if (getExperimentInfo("type") == 'Mutation Detection') {
			cellValues[count++] = rec.get('totalrefreactions');
		} else {
			cellValues[count++] = rec.get('noofreactions');
		}
		cellValues[count++] = rec.get('mastermixpartnumber1');
		//cellValues[count++] = rec.get('mnoofunits1');

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_10' name='Q_10' value ='"+ rec.get('mnoofunits1')+"' >";

		cellValues[count++] = convertCurrency(rec.get('mastermixcostperunit1'), region + "-" + currency);
		if( !isCSPCalc || isCPSoamiRNA){
			cellValues[count++] = VolumeDiscounts;
		}
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(10); return false;' class='EditTotalDiscount'>Edit</a></div>";
		if( !isCSPCalc ){
			cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='10' name='10' value ='"+ rec.get('mastermixdisc') +"' >";
		}
		if(rowTitle.indexOf('Digital PCR Master Mix (1.5mL)') == -1){ 			
			if( !isCSPCalc ){
				cellValues[count++] = convertCurrency((rec.get('mastermixcostperreaction1')), region + "-" + currency);
				cellValues[count++] = convertCurrency((rec.get('mmxcostpersample1')), region + "-" + currency);
			}			
			var priceperreaction = rec.get('mastermixcostperreaction1');
			var pricepersample = rec.get('mmxcostpersample1')
		}else { 
			if( !isCSPCalc ){
				cellValues[count++] = convertCurrency(((rec.get('mastermixcost1')) / (rec.get('noofreactions'))), region + "-" + currency);
				cellValues[count++] = convertCurrency(((rec.get('mastermixcost1')) / (getExperimentInfo('noofsamples'))), region + "-" + currency);
			}
			var priceperreaction = rec.get('mastermixcost1') / rec.get('noofreactions');
			var pricepersample = rec.get('mastermixcost1') / getExperimentInfo('noofsamples');
		}		
		cellValues[count++] = convertCurrency(rec.get('mastermixcostwithdisc1'), region + "-" + currency);
		
		detailspageinfo.add({
			id: 10,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.get('mnoofunits1'),
			unitprice: rec.get('mastermixcostperunit1'),
			volumediscount2: VolumeDiscounts,
			discount: rec.get('mastermixdisc'),
			priceperreaction: priceperreaction,
			pricepersample: pricepersample,
			netprice: rec.get('mastermixcostwithdisc1'),
			mastermixcostwithdisc:rec.get('mastermixcostwithdisc'),
			displaypriceperrxn:displaypriceperrxn,
			mnoofunits:rec.get('mnoofunits'),
			formattype: tType
		});
		addRow('productdetailstable', cellValues, false);
	}
	
	if (isNumber(rec.get('mnoofunits2')) && rec.get('mnoofunits2') > 0 ) {
		count = 0;
		rowTitle = rec.get('mastermix2');
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('mastermixpartnumber2'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('mastermixpartnumber2'));
		cellValues[count++] = rowTitleLink;
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Master Mix';
		if (getExperimentInfo("type") == 'Mutation Detection') {
			cellValues[count++] = rec.get('totalrefreactions');
		} else {
			cellValues[count++] = rec.get('noofreactions');
		}
		cellValues[count++] = rec.get('mastermixpartnumber2');
		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_73' name='Q_73' value ='"+ rec.get('mnoofunits2')+"' >";

		cellValues[count++] = convertCurrency(rec.get('mastermixcostperunit2'), region + "-" + currency);		
		cellValues[count++] = VolumeDiscounts;
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(73); return false;' class='EditTotalDiscount'>Edit</a></div>";
		
		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='73' name='73' value ='"+ rec.get('mastermixdisc') +"' >";
		cellValues[count++] = convertCurrency((rec.get('mastermixcost2') / rec.get('noofreactions')), region + "-" + currency);
		
		cellValues[count++] = convertCurrency((rec.get('mmxcostpersample2')), region + "-" + currency);
		cellValues[count++] = convertCurrency(rec.get('mastermixcostwithdisc2'), region + "-" + currency);;
		detailspageinfo.add({
			id: 73,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.get('mnoofunits2'),
			unitprice: rec.get('mastermixcostperunit2'),
			volumediscount2: VolumeDiscounts,
			discount: rec.get('mastermixdisc'),
			priceperreaction: cellValues[7],
			pricepersample: rec.get('mmxcostpersample2'),
			netprice: rec.get('mastermixcostwithdisc2'),
			volumediscount: 0,
			formattype: tType
		});
		addRow('productdetailstable', cellValues, false);
	}
	
	if (isNumber(rec.get('mnoofunits3')) && rec.get('mnoofunits3') > 0 ) {
		count = 0;
		rowTitle = rec.get('mastermix3');
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('mastermixpartnumber3'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('mastermixpartnumber3'));
		cellValues[count++] = rowTitleLink;
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Master Mix';
		if (getExperimentInfo("type") == 'Mutation Detection') {
			cellValues[count++] = rec.get('totalrefreactions');
		} else {
			cellValues[count++] = rec.get('noofreactions');
		}
		cellValues[count++] = rec.get('mastermixpartnumber3');
		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_74' name='Q_74' value ='"+ rec.get('mnoofunits3')+"' >";

		cellValues[count++] = convertCurrency(rec.get('mastermixcostperunit3'), region + "-" + currency);		
		cellValues[count++] = VolumeDiscounts;
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(73); return false;' class='EditTotalDiscount'>Edit</a></div>";
		
		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='74' name='74' value ='"+ rec.get('mastermixdisc') +"' >";
		cellValues[count++] = convertCurrency((rec.get('mastermixcost3') / rec.get('noofreactions')), region + "-" + currency);
		
		cellValues[count++] = convertCurrency((rec.get('mmxcostpersample3')), region + "-" + currency);
		cellValues[count++] = convertCurrency(rec.get('mastermixcostwithdisc3'), region + "-" + currency);;
		detailspageinfo.add({
			id: 74,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.get('mnoofunits3'),
			unitprice: rec.get('mastermixcostperunit3'),
			volumediscount2: VolumeDiscounts,
			discount: rec.get('mastermixdisc'),
			priceperreaction: cellValues[7],
			pricepersample: rec.get('mmxcostpersample3'),
			netprice: rec.get('mastermixcostwithdisc3'),
			volumediscount: 0,
			formattype: tType
		});
		addRow('productdetailstable', cellValues, false);
	}
	
	Ext.get('productlisttotalcost').update(convertCurrency(rec.get('totalcost'), region + "-" + currency));
	
	
	if (isNumber(rec.get('rtnoofunits')) && rec.get('rtnoofunits') > 0) {		
		count = 0;
		rowTitle = rec.get('rtproduct');
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('rtpartnumber'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('rtpartnumber'));		
		cellValues[count++] = rowTitleLink;
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'RT';
		cellValues[count++] = rec.get('noofreactions');
		cellValues[count++] = rec.get('rtpartnumber');
		//cellValues[count++] = rec.get('rtnoofunits');

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_1' name='Q_1' value ='"+ rec.get('rtnoofunits')+"' >";

		cellValues[count++] = convertCurrency(Math.round(rec.get('rtcostperunit')), region + "-" + currency);
		if( !isCSPCalc || isCPSoamiRNA ){
			cellValues[count++] = VolumeDiscounts;
		}
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(1); return false;' class='EditTotalDiscount'>Edit</a></div>";
		if( !isCSPCalc ){
			cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='1' name='1' value ='"+ preamprtperc+"' >";
		}
		//cellValues[count++] = preamprtperc + discHtml;
		if( !isCSPCalc ){
			cellValues[count++] = convertCurrency((rec.get('rtcostperreaction')), region + "-" + currency);
			cellValues[count++] = convertCurrency((rec.get('rtcostpersample')), region + "-" + currency);
		}
		cellValues[count++] = convertCurrency(roundNumber(rec.get('totalrtcost'), 2), region + "-" + currency);
		detailspageinfo.add({
			id: 1,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity:  rec.get('rtnoofunits'),
			unitprice: rec.get('rtcostperunit'),
			volumediscount2: VolumeDiscounts,
			discount: parseFloat(preamprtperc),
			priceperreaction: rec.get('rtcostperreaction'),
			pricepersample: rec.get('rtcostpersample'),
			netprice: rec.get('totalrtcost')
		});
		addRow('productdetailstable', cellValues, false);
	}
	
	if (isNumber(rec.get('rtnoofunits1')) && rec.get('rtnoofunits1') > 0) {		
		count = 0;
		rowTitle = rec.get('rtproduct1');
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('rtpartnumber1'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('rtpartnumber1'));
		cellValues[count++] = rowTitleLink;
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'RT';
		cellValues[count++] = rec.get('noofreactions');
		cellValues[count++] = rec.get('rtpartnumber1');
		//cellValues[count++] = rec.get('rtnoofunits1');

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_2' name='Q_2' value ='"+ rec.get('rtnoofunits1')+"' >";

		cellValues[count++] = convertCurrency(Math.round(rec.get('rtcostperunit1')), region + "-" + currency);
		if( !isCSPCalc || isCPSoamiRNA ){
			cellValues[count++] = VolumeDiscounts;
		}
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(2); return false;' class='EditTotalDiscount'>Edit</a></div>";
		if( !isCSPCalc ){
			cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='2' name='2' value ='"+ preamprtperc +"' >";
		}
		if( !isCSPCalc ){
			//cellValues[count++] = preamprtperc + discHtml;
			cellValues[count++] = convertCurrency((rec.get('rtcostperreaction1')), region + "-" + currency);
			cellValues[count++] = convertCurrency((rec.get('rtcostpersample1')), region + "-" + currency);
		}
		cellValues[count++] = convertCurrency(roundNumber(rec.get('totalrtcost1'), 2), region + "-" + currency);
		detailspageinfo.add({
			id: 2,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.get('rtnoofunits1'),
			unitprice: rec.get('rtcostperunit1'),
			discount: parseFloat(preamprtperc),
			volumediscount2: VolumeDiscounts,
			priceperreaction: rec.get('rtcostperreaction1'),
			pricepersample: rec.get('rtcostpersample1'),
			netprice: rec.get('totalrtcost1')
		});
		addRow('productdetailstable', cellValues, false);
	}
	
	if (isNumber(rec.get('megaplexprimerpoolshumanunits')) && rec.get('megaplexprimerpoolshumanunits') > 0) {
		var rt_tools = $('input[name=rt_tools]:radio:checked').val();
		if(rt_tools == "Megaplex"){
			var purl = getExperimentInfo('species') == "Human" ? 'Megaplex&#174; Primer Pools, Human' : 'Megaplex&#174; Primer Pools, Rodent';
		} else {
			var purl = "Custom RT pool";
		}
		count = 0;	
		rowTitle = purl;
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('accessory5partnumber'), rec.get('producturl')));	
		VolumeDiscounts = getVolumeDiscount(rec.get('accessory5partnumber'));
		cellValues[count++] = rowTitleLink;
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Accessories';
		cellValues[count++] = rec.get('noofreactions');
		cellValues[count++] = rec.get('accessory5partnumber');
		//cellValues[count++] = rec.get('megaplexprimerpoolshumanunits');

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_8' name='Q_8' value ='"+ rec.get('megaplexprimerpoolshumanunits')+"' >";

		cellValues[count++] = convertCurrency(rec.get('assay5costperUnts'), region + "-" + currency);
		if( !isCSPCalc || isCPSoamiRNA){
			cellValues[count++] = VolumeDiscounts;
		}
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(8); return false;' class='EditTotalDiscount'>Edit</a></div>";
		if( !isCSPCalc ){
			cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='8' name='8' value ='"+ accessoriesperc +"' >";
		}
		//cellValues[count++] = preamprtperc + discHtml;
		if( !isCSPCalc ){
			cellValues[count++] = convertCurrency(((rec.get('megaplexprimerpoolshumancost')) / (rec.get('noofreactions'))), region + "-" + currency);
			cellValues[count++] = convertCurrency(
			((rec.get('megaplexprimerpoolshumancost')) / (getExperimentInfo('noofsamples'))), region + "-" + currency);
		}
		cellValues[count++] = convertCurrency((rec.get('megaplexprimerpoolshumancost')), region + "-" + currency);
		
		detailspageinfo.add({
			id: 8,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.get('megaplexprimerpoolshumanunits'),
			unitprice: rec.get('assay5costperUnts'),
			volumediscount2: VolumeDiscounts,
			discount: parseFloat(preamprtperc),
			priceperreaction: (rec.get('megaplexprimerpoolshumancost')) / (rec.get('noofreactions')),
			pricepersample: (rec.get('megaplexprimerpoolshumancost')) / (getExperimentInfo('noofsamples')),
			netprice: roundNumber(rec.get('megaplexprimerpoolshumancost'), 2)
		});
		addRow('productdetailstable', cellValues, false);
	}
	
	if (isNumber(rec.get('preampnoofunits')) && rec.get('preampnoofunits') > 0) {		
		count = 0;
		rowTitle = rec.get('preampproduct');
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('preamppartnumber'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('preamppartnumber'));
		cellValues[count++] = rowTitleLink;
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Pre-Amp';
		cellValues[count++] = rec.get('noofreactions');
		cellValues[count++] = rec.get('preamppartnumber');
		//cellValues[count++] = rec.get('preampnoofunits');

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_3' name='Q_3' value ='"+ rec.get('preampnoofunits')+"' >";

		cellValues[count++] = convertCurrency(Math.round(rec.get('preampcostperunit')), region + "-" + currency);
		if( !isCSPCalc || isCPSoamiRNA){
			cellValues[count++] = VolumeDiscounts;
		}
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(3); return false;' class='EditTotalDiscount'>Edit</a></div>";
		if( !isCSPCalc ){
			cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='3' name='3' value ='"+ preamprtperc +"' >";
		}
		//cellValues[count++] = preamprtperc + discHtml;
		if( !isCSPCalc ){
			cellValues[count++] = convertCurrency((rec.get('preampcostperreaction')), region + "-" + currency);
			cellValues[count++] = convertCurrency((rec.get('preampcostpersample')), region + "-" + currency);
		}
		cellValues[count++] = convertCurrency(roundNumber(rec.get('totalpreampcost'), 2), region + "-" + currency);
		detailspageinfo.add({
			id: 3,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.get('preampnoofunits'),
			unitprice: rec.get('preampcostperunit'),
			volumediscount2: VolumeDiscounts,
			discount: parseFloat(preamprtperc),
			priceperreaction: rec.get('preampcostperreaction'),
			pricepersample: rec.get('preampcostpersample'),
			netprice: rec.get('totalpreampcost')
		});
		addRow('productdetailstable', cellValues, false);
	}
	
	if (isNumber(rec.get('preampnoofunits1')) && rec.get('preampnoofunits1') > 0) {		
		count = 0;
		rowTitle = rec.get('preampproduct1');
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('preamppartnumber1'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('preamppartnumber1'));
		cellValues[count++] = rowTitleLink;
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Pre-Amp';
		cellValues[count++] = rec.get('noofreactions');
		cellValues[count++] = rec.get('preamppartnumber1');
		//cellValues[count++] = rec.get('preampnoofunits');

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_81' name='Q_81' value ='"+ rec.get('preampnoofunits1')+"' >";

		cellValues[count++] = convertCurrency(Math.round(rec.get('preampcostperunit1')), region + "-" + currency);
		if( !isCSPCalc || isCPSoamiRNA){
			cellValues[count++] = VolumeDiscounts;
		}
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(3); return false;' class='EditTotalDiscount'>Edit</a></div>";
		if( !isCSPCalc ){
			cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='81' name='81' value ='"+ preamprtperc +"' >";
		}
		//cellValues[count++] = preamprtperc + discHtml;
		if( !isCSPCalc ){
			cellValues[count++] = convertCurrency((rec.get('preampcostperreaction1')), region + "-" + currency);
			cellValues[count++] = convertCurrency((rec.get('preampcostpersample1')), region + "-" + currency);
		}
		cellValues[count++] = convertCurrency(roundNumber(rec.get('totalpreampcost1'), 2), region + "-" + currency);
		detailspageinfo.add({
			id: 81,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.get('preampnoofunits1'),
			unitprice: rec.get('preampcostperunit1'),
			volumediscount2: VolumeDiscounts,
			discount: parseFloat(preamprtperc),
			priceperreaction: rec.get('preampcostperreaction1'),
			pricepersample: rec.get('preampcostpersample1'),
			netprice: rec.get('totalpreampcost1')
		});
		addRow('productdetailstable', cellValues, false);
	}
	
	if (isNumber(rec.get('preampprimerpoolsnoofunits')) && rec.get('preampprimerpoolsnoofunits') > 0) {		
		count = 0;
		rowTitle = rec.get('preampprimerpools');
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('preprimerpoolpartnumber'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('preprimerpoolpartnumber'));
		cellValues[count++] = rowTitleLink;
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Primer Pools';
		cellValues[count++] = rec.get('noofreactions');
		cellValues[count++] = rec.get('preprimerpoolpartnumber');
		//cellValues[count++] = rec.get('preampprimerpoolsnoofunits');

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_12' name='Q_12' value ='"+ rec.get('preampprimerpoolsnoofunits')+"' >";

		cellValues[count++] = convertCurrency((rec.get('preprimerpoolspriceperunit')), region + "-" + currency);
		if( !isCSPCalc || isCPSoamiRNA){
			cellValues[count++] = VolumeDiscounts;
		}
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(12); return false;' class='EditTotalDiscount'>Edit</a></div>";
		if( !isCSPCalc ){
			cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='12' name='12' value ='"+ preamprtperc +"' >";
		}
		//cellValues[count++] = preamprtperc + discHtml;
		if( !isCSPCalc ){
			cellValues[count++] = convertCurrency(((rec.get('totalpreampprimerpoolspricecost')) / (rec.get('noofreactions'))), region + "-" + currency);
			cellValues[count++] = convertCurrency(((rec.get('totalpreampprimerpoolspricecost')) / (getExperimentInfo('noofsamples'))), region + "-" + currency);
		}
		cellValues[count++] = convertCurrency((rec.get('totalpreampprimerpoolspricecost')), region + "-" + currency);;
		detailspageinfo.add({
			id: 12,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.get('preampprimerpoolsnoofunits'),
			unitprice: rec.get('preprimerpoolspriceperunit'),
			volumediscount2: VolumeDiscounts,
			discount: parseFloat(preamprtperc),
			priceperreaction: (rec.get('totalpreampprimerpoolspricecost')) / (rec.get('noofreactions')),
			pricepersample: (rec.get('totalpreampprimerpoolspricecost')) / (getExperimentInfo('noofsamples')),
			netprice: rec.get('totalpreampprimerpoolspricecost')
		});
		addRow('productdetailstable', cellValues, false);
	}
	
	if (isNumber(rec.get('rtprimerpoolsnoofunits')) && rec.get('rtprimerpoolsnoofunits') > 0) {
		count = 0;
		rowTitle = rec.get('rtprimerpools');
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('rtprimerpoolpartnumber'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('rtprimerpoolpartnumber'));
		cellValues[count++] = rowTitleLink;
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Primer Pools';
		cellValues[count++] = rec.get('noofreactions');
		cellValues[count++] = rec.get('rtprimerpoolpartnumber');
		//cellValues[count++] = rec.get('rtprimerpoolsnoofunits');

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_11' name='Q_11' value ='"+ rec.get('rtprimerpoolsnoofunits')+"' >";

		cellValues[count++] = convertCurrency(rec.get('rtprimerpoolspriceperunit'), region + "-" + currency);
		cellValues[count++] = VolumeDiscounts;
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(11); return false;' class='EditTotalDiscount'>Edit</a></div>";

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='11' name='11' value ='"+ preamprtperc +"' >";

		//cellValues[count++] = preamprtperc + discHtml;
		cellValues[count++] = convertCurrency(((rec.get('totalrtprimerpoolspricecost')) / (rec.get('noofreactions'))), region + "-" + currency);
		cellValues[count++] = convertCurrency(
		((rec.get('totalrtprimerpoolspricecost')) / (getExperimentInfo('noofsamples'))), region + "-" + currency);
		cellValues[count++] = convertCurrency((rec.get('totalrtprimerpoolspricecost')), region + "-" + currency);;
		detailspageinfo.add({
			id: 11,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.get('rtprimerpoolsnoofunits'),
			unitprice: rec.get('rtprimerpoolspriceperunit'),
			volumediscount2: VolumeDiscounts,
			discount: parseFloat(preamprtperc),
			priceperreaction: (rec.get('totalrtprimerpoolspricecost')) / (rec.get('noofreactions')),
			pricepersample: (rec.get('totalrtprimerpoolspricecost')) / (getExperimentInfo('noofsamples')),
			netprice: rec.get('totalrtprimerpoolspricecost')
		});
		addRow('productdetailstable', cellValues, false);
	}
	
	if (isNumber(rec.get('openarray384wellsampleplatesunits')) && rec.get('openarray384wellsampleplatesunits') > 0) {
		
		count = 0;
		rowTitle = 'OpenArray&#174; 384-well Sample Plates';
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('accessory1partnumber'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('accessory1partnumber'));
		cellValues[count++] = rowTitleLink;		
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Accessories';
		cellValues[count++] = rec.get('noofreactions');
		cellValues[count++] = rec.get('accessory1partnumber');
		//cellValues[count++] = rec.get('openarray384wellsampleplatesunits');
		
		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_4' name='Q_4' value ='"+ rec.get('openarray384wellsampleplatesunits')+"' >";

		cellValues[count++] = convertCurrency((rec.get('openarray384wellsampleplatescost') / rec.get('openarray384wellsampleplatesunits')), region + "-" + currency);
		if( !isCSPCalc || isCPSoamiRNA){
			cellValues[count++] = VolumeDiscounts;
		}
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(4); return false;' class='EditTotalDiscount'>Edit</a></div>";
		if( !isCSPCalc ){
			cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='4' name='4' value ='"+ rec.get('accessoriesdisc') +"' >";
		}
		//cellValues[count++] = rec.get('accessoriesdisc') + discHtml;
		if( !isCSPCalc ){
			cellValues[count++] = convertCurrency(((rec.get('openarray384wellsampleplatescost')) / (rec.get('noofreactions'))), region + "-" + currency);
			cellValues[count++] = convertCurrency(
			((rec.get('openarray384wellsampleplatescost') * (1 - (rec.get('accessoriesdisc') / 100))) / (getExperimentInfo('noofsamples'))), region + "-" + currency);
		}
		cellValues[count++] = convertCurrency((rec.get('openarray384wellsampleplatescost') * (1 - (rec.get('accessoriesdisc') / 100))), region + "-" + currency);
		detailspageinfo.add({
			id: 4,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.get('openarray384wellsampleplatesunits'),
			unitprice: (rec.get('openarray384wellsampleplatescost') / rec.get('openarray384wellsampleplatesunits')),
			volumediscount2: VolumeDiscounts,
			discount: rec.get('accessoriesdisc'),
			priceperreaction: (rec.get('openarray384wellsampleplatescost')) / (rec.get('noofreactions')),
			pricepersample: (rec.get('openarray384wellsampleplatescost')) / (getExperimentInfo('noofsamples')),
			netprice: (rec.get('openarray384wellsampleplatescost') * (1 - (rec.get('accessoriesdisc') / 100)))
		});
		addRow('productdetailstable', cellValues, false);
	}
	
	if (isNumber(rec.get('openarrayaccufillsystemtipsunits')) && rec.get('openarrayaccufillsystemtipsunits') > 0) {		
		count = 0;
		rowTitle = 'OpenArray&#174; AccuFill System Tips';
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('accessory2partnumber'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('accessory2partnumber'));
		cellValues[count++] = rowTitleLink;
		//cellValues[count++] = 'OpenArray&#174; AccuFill System Tips';
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Accessories';
		cellValues[count++] = rec.get('noofreactions');
		cellValues[count++] = rec.get('accessory2partnumber');
		//cellValues[count++] = rec.get('openarrayaccufillsystemtipsunits');
		
		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_5' name='Q_5' value ='"+ rec.get('openarrayaccufillsystemtipsunits')+"' >";

		cellValues[count++] = convertCurrency((rec.get('openarrayaccufillsystemtipscost') / rec.get('openarrayaccufillsystemtipsunits')), region + "-" + currency);
		if( !isCSPCalc || isCPSoamiRNA){
			cellValues[count++] = VolumeDiscounts;
		}
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(5); return false;' class='EditTotalDiscount'>Edit</a></div>";
		if( !isCSPCalc ){
			cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='5' name='5' value ='"+ rec.get('accessoriesdisc') +"' >";
		}
		//cellValues[count++] = rec.get('accessoriesdisc') + discHtml;
		if( !isCSPCalc ){
			cellValues[count++] = convertCurrency(((rec.get('openarrayaccufillsystemtipscost')) / (rec.get('noofreactions'))), region + "-" + currency);
			cellValues[count++] = convertCurrency(
			((rec.get('openarrayaccufillsystemtipscost') * (1 - (rec.get('accessoriesdisc') / 100))) / (getExperimentInfo('noofsamples'))), region + "-" + currency);
		}
		cellValues[count++] = convertCurrency((rec.get('openarrayaccufillsystemtipscost') * (1 - (rec.get('accessoriesdisc') / 100))), region + "-" + currency);
		detailspageinfo.add({
			id: 5,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.get('openarrayaccufillsystemtipsunits'),
			unitprice: (rec.get('openarrayaccufillsystemtipscost') / rec.get('openarrayaccufillsystemtipsunits')),
			volumediscount2: VolumeDiscounts,
			discount: rec.get('accessoriesdisc'),
			priceperreaction: (rec.get('openarrayaccufillsystemtipscost')) / (rec.get('noofreactions')),
			pricepersample: (rec.get('openarrayaccufillsystemtipscost')) / (getExperimentInfo('noofsamples')),
			netprice: roundNumber(rec.get('openarrayaccufillsystemtipscost') * (1 - (rec.get('accessoriesdisc') / 100)), 2)
		});
		addRow('productdetailstable', cellValues, false);
	}
	
	if (isNumber(rec.get('openarrayaccufillsystemtips10packunits')) && rec.get('openarrayaccufillsystemtips10packunits') > 0) {		
		count = 0;
		rowTitle = 'OpenArray&#174; AccuFill System Tips, 10 pack';
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('accessory3partnumber'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('accessory3partnumber'));
		cellValues[count++] = rowTitleLink;
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Accessories';
		cellValues[count++] = rec.get('noofreactions');
		cellValues[count++] = rec.get('accessory3partnumber');
		//cellValues[count++] = rec.get('openarrayaccufillsystemtips10packunits');

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_6' name='Q_6' value ='"+ rec.get('openarrayaccufillsystemtips10packunits')+"' >";

		cellValues[count++] = convertCurrency((rec.get('openarrayaccufillsystemtips10packcost') / rec.get('openarrayaccufillsystemtips10packunits')), region + "-" + currency);
		if( !isCSPCalc || isCPSoamiRNA){
			cellValues[count++] = VolumeDiscounts;
		}
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(6); return false;' class='EditTotalDiscount'>Edit</a></div>";
		if( !isCSPCalc ){
			cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='6' name='6' value ='"+ rec.get('accessoriesdisc') +"' >";
		}
		//cellValues[count++] = rec.get('accessoriesdisc') + discHtml;
		if( !isCSPCalc ){
			cellValues[count++] = convertCurrency(((rec.get('openarrayaccufillsystemtips10packcost')) / (rec.get('noofreactions'))), region + "-" + currency);
			cellValues[count++] = convertCurrency(
			((rec.get('openarrayaccufillsystemtips10packcost') * (1 - (rec.get('accessoriesdisc') / 100))) / (getExperimentInfo('noofsamples'))), region + "-" + currency);
		}
		cellValues[count++] = convertCurrency((rec.get('openarrayaccufillsystemtips10packcost') * (1 - (rec.get('accessoriesdisc') / 100))), region + "-" + currency);
		detailspageinfo.add({
			id: 6,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.get('openarrayaccufillsystemtips10packunits'),
			unitprice: (rec.get('openarrayaccufillsystemtips10packcost') / rec.get('openarrayaccufillsystemtips10packunits')),
			volumediscount2: VolumeDiscounts,
			discount: rec.get('accessoriesdisc'),
			priceperreaction: (rec.get('openarrayaccufillsystemtips10packcost')) / (rec.get('noofreactions')),
			pricepersample: (rec.get('openarrayaccufillsystemtips10packcost')) / (getExperimentInfo('noofsamples')),
			netprice: (rec.get('openarrayaccufillsystemtips10packcost') * (1 - (rec.get('accessoriesdisc') / 100)))
		});
		addRow('productdetailstable', cellValues, false);
	}
	
	if (isNumber(rec.get('openarrayrealtimepcraccessorieskitunits')) && rec.get('openarrayrealtimepcraccessorieskitunits') > 0) {		
		count = 0;
		rowTitle = rec.get('realtimePCRname');
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('accessory4partnumber'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('accessory4partnumber'));
		cellValues[count++] = rowTitleLink;
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Accessories';
		cellValues[count++] = rec.get('noofreactions');
		cellValues[count++] = rec.get('accessory4partnumber');
		//cellValues[count++] = rec.get('openarrayrealtimepcraccessorieskitunits');

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_7' name='Q_7' value ='"+ rec.get('openarrayrealtimepcraccessorieskitunits')+"' >";

		cellValues[count++] = convertCurrency((rec.get('openarrayrealtimepcraccessorieskitcost') / rec.get('openarrayrealtimepcraccessorieskitunits')), region + "-" + currency);
		if( !isCSPCalc || isCPSoamiRNA){
			cellValues[count++] = VolumeDiscounts;
		}
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(7); return false;' class='EditTotalDiscount'>Edit</a></div>";
		if( !isCSPCalc ){
			cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='7' name='7' value ='"+ rec.get('accessoriesdisc') +"' >";
		}
		//cellValues[count++] = rec.get('accessoriesdisc') + discHtml;
		if( !isCSPCalc ){
			cellValues[count++] = convertCurrency(((rec.get('openarrayrealtimepcraccessorieskitcost')) / (rec.get('noofreactions'))), region + "-" + currency);
			cellValues[count++] = convertCurrency(
			((rec.get('openarrayrealtimepcraccessorieskitcost') * (1 - (rec.get('accessoriesdisc') / 100))) / (getExperimentInfo('noofsamples'))), region + "-" + currency);
		}
		cellValues[count++] = convertCurrency((rec.get('openarrayrealtimepcraccessorieskitcost') * (1 - (rec.get('accessoriesdisc') / 100))), region + "-" + currency);
		detailspageinfo.add({
			id: 7,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity:  rec.get('openarrayrealtimepcraccessorieskitunits'),
			unitprice: (rec.get('openarrayrealtimepcraccessorieskitcost') / rec.get('openarrayrealtimepcraccessorieskitunits')),
			volumediscount2: VolumeDiscounts,
			discount: rec.get('accessoriesdisc'),
			priceperreaction: (rec.get('openarrayrealtimepcraccessorieskitcost')) / (rec.get('noofreactions')),
			pricepersample: (rec.get('openarrayrealtimepcraccessorieskitcost') * (1 - (rec.get('accessoriesdisc') / 100))) / (getExperimentInfo('noofsamples')),
			netprice: roundNumber(rec.get('openarrayrealtimepcraccessorieskitcost') * (1 - (rec.get('accessoriesdisc') / 100)), 2)
		});
		addRow('productdetailstable', cellValues, false);
	}
	
	
	
	if (isNumber(rec.get('uvchipsnoofunits')) &&  rec.get('uvchipsnoofunits') > 0) {		
		var purl = rec.get('uvproduct');
		count = 0;	
		rowTitle = purl;
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('uvpartno'), rec.get('producturl')));	
		VolumeDiscounts = getVolumeDiscount(rec.get('uvpartno'));
		cellValues[count++] = rowTitleLink;
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Accessories';
		cellValues[count++] = rec.get('noofuvrxns');
		//console.log("Access -"+rec.get('noofuvrxns'));
		cellValues[count++] = rec.get('uvpartno');
		//cellValues[count++] = rec.get('megaplexprimerpoolshumanunits');

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_79' name='Q_79' value ='"+ rec.get('uvchipsnoofunits')+"' >";

		cellValues[count++] = convertCurrency(rec.get('uvchipscostperunit') , region + "-" + currency);
		cellValues[count++] = VolumeDiscounts;
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(79); return false;' class='EditTotalDiscount'>Edit</a></div>";

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='79' name='79' value ='"+ rec.get('uvchipsdisc') +"' >";
		cellValues[count++] = convertCurrency(rec.get('UvChipsCostPerReaction'), region + "-" + currency);
		cellValues[count++] = convertCurrency((rec.get('uvCostPerSample')), region + "-" + currency);
		
		var priceperreact = rec.get('UvChipsCostPerReaction');
		var pricepersample = rec.get('uvCostPerSample');		
		var noOfUnits= rec.get('uvchipsnoofunits');
		var unitPrice = rec.get('uvchipscostperunit');
		var discount = rec.get('uvchipsdisc');
		var netPrice = (noOfUnits * unitPrice) * (1 - (discount / 100));
		cellValues[count++] = convertCurrency(netPrice, region + "-" + currency);
		detailspageinfo.add({
			id: 79,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.get('uvchipsnoofunits'),
			unitprice: roundNumber(rec.get('uvchipscostperunit'), 2),
			volumediscount2: VolumeDiscounts,
			discount: parseFloat(rec.get('uvchipsdisc')),
			priceperreaction: priceperreact,
			pricepersample: pricepersample,
			netprice: roundNumber(netPrice, 2)
		});
		addRow('productdetailstable', cellValues, false);
	}

	if (isNumber(rec.get('cDNAKitQty')) &&  rec.get('cDNAKitQty') > 0) {
		var cDNAKit = rec.get('cDNAKit');
		count = 0;
		rowTitle = cDNAKit;
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('cDNAKitPartNo'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('cDNAKitPartNo'));
		cellValues[count++] = rowTitleLink;
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Accessories';
		cellValues[count++] = getExperimentInfo('nooftargets')
					* getExperimentInfo('noofreplicates') * getExperimentInfo('noofsamples');
		//console.log("Access -"+rec.get('noofuvrxns'));
		cellValues[count++] = rec.get('cDNAKitPartNo');
		//cellValues[count++] = rec.get('megaplexprimerpoolshumanunits');

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_80' name='Q_80' value ='"+ rec.get('cDNAKitQty')+"' >";

		cellValues[count++] = convertCurrency(rec.get('cDNAKitCost') , region + "-" + currency);
		cellValues[count++] = VolumeDiscounts;
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(79); return false;' class='EditTotalDiscount'>Edit</a></div>";

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='80' name='80' value ='"+ rec.get('volumediscount') +"' >";
		cellValues[count++] = convertCurrency(rec.get('cDNAkitCostPerRxn'), region + "-" + currency);
		cellValues[count++] = convertCurrency((rec.get('cDNAtotalKitCost')/getExperimentInfo('noofsamples')), region + "-" + currency);

		cellValues[count++] = convertCurrency(rec.get('cDNACostWithVolDisc'), region + "-" + currency);
		detailspageinfo.add({
			id: 80,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.get('cDNAKitQty'),
			unitprice: roundNumber(rec.get('cDNAKitCost'), 2),
			volumediscount2: VolumeDiscounts,
			discount: parseFloat(rec.get('volumediscount')),
			priceperreaction: rec.get('cDNAkitCostPerRxn'),
			pricepersample: rec.get('cDNAkitCostPerRxn'),
			netprice: roundNumber(rec.get('cDNACostWithVolDisc'), 2)
		});
		addRow('productdetailstable', cellValues, false);
	}

	if (isNumber(rec.get('ipcunits')) && rec.get('ipcunits') > 0) {		
		count = 0;
		rowTitle = rec.get('ipcname');
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('ipcpartnumber'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('ipcpartnumber'));
		cellValues[count++] = rowTitleLink;
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'IPC Kit';
		cellValues[count++] = rec.get('totalrefreactions');
		cellValues[count++] = rec.get('ipcpartnumber');
		//cellValues[count++] = rec.get('ipcqty');

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_13' name='Q_13' value ='"+ rec.get('ipcqty')+"' >";

		cellValues[count++] = convertCurrency(Math.round(rec.get('ipcprice')), region + "-" + currency);
		cellValues[count++] = VolumeDiscounts;
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(13); return false;' class='EditTotalDiscount'>Edit</a></div>";

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='13' name='13' value ='"+ preamprtperc +"' >";

		//cellValues[count++] = preamprtperc + discHtml;
		cellValues[count++] = convertCurrency((rec.get('ipcperreaction')), region + "-" + currency);
		cellValues[count++] = convertCurrency((rec.get('ipcpersample')), region + "-" + currency);
		cellValues[count++] = convertCurrency(roundNumber(rec.get('ipcnetprice'), 2), region + "-" + currency);
		detailspageinfo.add({
			id: 13,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.get('ipcqty'),
			unitprice: rec.get('ipcprice'),
			volumediscount2: VolumeDiscounts,
			discount: parseFloat(preamprtperc),
			priceperreaction: rec.get('ipcpersample'),
			pricepersample: rec.get('ipcprice'),
			netprice: rec.get('ipcnetprice')
		});
		addRow('productdetailstable', cellValues, false);
	}
	
	
	if (isNumber(rec.get('digitalchipsnoofunits')) && rec.get('digitalchipsnoofunits') > 0) {		
		updateExperimentInfo("isDigitalPCR", "true");
		count = 0;
		rowTitle = rec.get('digitalchips');
		//rowTitleLink = getProductLink(rowTitle,rec.get('producturl'));
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.get('digitalchipspartnumber'), rec.get('producturl')));
		VolumeDiscounts = getVolumeDiscount(rec.get('digitalchipspartnumber'));
		var QS3D = $( "#QS3D" ).hasClass( "tbuttonselected" );
		if(rowTitle.indexOf('SNP') > -1){
			cellValues[count++] = rowTitleLink+ "*";
		} else {
			cellValues[count++] = rowTitleLink;
		}
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Assay';		
		//console.log("Assay - "+rec.get('noofreactions'));
		cellValues[count++] = rec.get('noofreactions');
		cellValues[count++] = rec.get('digitalchipspartnumber');
		//cellValues[count++] = rec.get('digitalchipsnoofunits');

		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' id='Q_71' name='Q_71' value ='"+ rec.get('digitalchipsnoofunits')+"' >";

		cellValues[count++] = convertCurrency(rec.get('digitalchipspriceperunit'), region + "-" + currency);		
		cellValues[count++] = VolumeDiscounts;
		var discHtml = "<div><a href='#' onclick='showEditDiscPopup(71); return false;' class='EditTotalDiscount'>Edit</a></div>";
		//cellValues[count++] =  0 + discHtml;
		
		cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='71' name='71' value ='"+ assayperc +"' >";

		cellValues[count++] = convertCurrency((rec.get('digitalchipscostperreaction')), region + "-" + currency);
		cellValues[count++] = convertCurrency((rec.get('digitalchipspersample')), region + "-" + currency);
		cellValues[count++] = convertCurrency(rec.get('totaldigitalchipscost'), region + "-" + currency);;
		detailspageinfo.add({
			id: 71,
			product: rowTitle,
			//type: cellValues[1],
			type: rec.get('type'),
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.get('digitalchipsnoofunits'),
			unitprice: rec.get('digitalchipspriceperunit'),
			volumediscount2: VolumeDiscounts,
			discount: 0,
			priceperreaction: cellValues[7],
			pricepersample: rec.get('digitalchipspersample'),
			netprice: rec.get('totaldigitalchipscost'),
			volumediscount: 0,
			tubenoofreactions: rec.get('tubenoofreactions')
		});
		addRow('productdetailstable', cellValues, false);
	}
	Ext.get('productlisttotalcost').update(convertCurrency(rec.get('totalcost'), region + "-" + currency));
	//prepareMailHTML(rec);

	copyMinQtyfromDetailsInfo();
	createSpinner();
	prepareMailDiscHTML();
	//toactivateSpinner();
	
	return false;
}


function showSybrDetails(type) {
	detailspageinfo.removeAll();
	$("#editInputBt").hide();
	Ext.get('sybrdetails').removeCls('hidden');
	Ext.get('sybrdetails').addCls('visible');
	Ext.get('sybrtotalcost_div').removeCls('hidden');
	Ext.get('sybrtotalcost_div').addCls('visible');
	
	clearTable('productdetailstable');
	var rec = null;
	if (type == "n") {
		rec = sybr;
	} 
	/*else if (type == "o") {
		rec = osybr;
	} else {
		rec = osybrf;
	}*/
	managetab("details", "steptwo", "tabbar");
	/*Ext.get('steptwo').removeCls('visible');
	Ext.get('steptwo').addCls('hidden');
	Ext.get('details').removeCls('hidden');
	Ext.get('details').addCls('visible');*/
	
	cellValues = new Array(9); //Madhu asked to remove type column on 09/01/2015
	//if (type == "o" || type == "f" || type == "n") {
		var count = 0;
		cellValues[count++] = rec.format;
		//Madhu asked to remove type column on 09/01/2015 cellValues[count++] = 'Array';
		cellValues[count++] = rec.noofreactions;
		if(rec.partnumber == undefined){
			cellValues[count++] = "Multiple";
		} else {
			cellValues[count++] = rec.partnumber;
		}
		cellValues[count++] = rec.noofunits;
		cellValues[count++] = convertCurrency(rec.assayscostperunit, region + "-" + currency);
		cellValues[count++] = getVolumeDiscount(0);
		cellValues[count++] = "0";
		cellValues[count++] = convertCurrency(rec.assaycostperreaction, region + "-" + currency);
		cellValues[count++] = convertCurrency(rec.assaycostpersample, region + "-" + currency);
		cellValues[count++] = convertCurrency(rec.assayscostwithvoldisc, region + "-" + currency);
		
		detailspageinfo.add({
			id: 301,
			product: rec.format,
			//type: cellValues[1],
			type: "SYBR",
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.noofunits,
			unitprice: rec.assayscostperunit,
			volumediscount2: 0,
			discount: 0,
			priceperreaction: cellValues[7],
			pricepersample: rec.assaycostpersample,
			netprice: rec.assayscostwithvoldisc,
			volumediscount: 0
		});
		
		addRow('productdetailstable', cellValues, false);
	//}
	//if (type == "n") {
		rowTitle = rec.mastermix;
		rowTitleLink = getProductLink(rowTitle,getProductURL(rec.mastermixpartnumber), rec.producturl);
		var viewOtherMMBtn = '<span class="viewParnt" id=""><div id="viewMMParntDiv" class="viewParntDivDetPge viewParntMMPge"></div><button class="viewDet" onclick="ViewOtherMMDetails(\''+rec.format+'\',\''+rec.mastermix+'\',\''+rec.pno+'\'); return false;">View Other Format</button></span>&nbsp;';
		var count = 0;
		cellValues[count++] = rowTitleLink + viewOtherMMBtn;
		//cellValues[count++] = 'Master Mix';
		cellValues[count++] = rec.noofreactions;
		cellValues[count++] = rec.mastermixpartnumber;
		cellValues[count++] = rec.mnoofunits;
		cellValues[count++] = convertCurrency(rec.mastermixcostperunit, region + "-" + currency);
		cellValues[count++] = getVolumeDiscount(rec.mastermixpartnumber);
		cellValues[count++] = rec.mastermixdisc;
		cellValues[count++] = convertCurrency((rec.mastermixcost / rec.noofreactions), region + "-" + currency);
		cellValues[count++] = convertCurrency((rec.mmxcostpersample), region + "-" + currency);
		cellValues[count++] = convertCurrency(rec.mastermixcostwithdisc, region + "-" + currency);
		
		detailspageinfo.add({
			id: 302,
			product: rowTitle,
			//type: cellValues[1],
			type: "Master Mix",
			noofreactions: cellValues[1],
			partnumber: cellValues[2],
			quantity: rec.mnoofunits,
			unitprice: rec.mastermixcostperunit,
			volumediscount2: 0,
			discount: 0,
			priceperreaction: cellValues[7],
			pricepersample: rec.mmxcostpersample,
			netprice: rec.mastermixcostwithdisc,
			volumediscount: 0
		});
		
		addRow('productdetailstable', cellValues, false);
	//}
	
	Ext.get('selProductname').update(rec.format);
	Ext.get('totalcost').update(convertCurrency((rec.totalcost), region + "-" + currency));
	Ext.get('costperreaction').update(convertCurrency(Math.round(rec.totalcostperreaction), region + "-" + currency));
	Ext.get('costpersample').update(convertCurrency((rec.totalcostpersample), region + "-" + currency));
	Ext.get('totaltime').update(rec.noofhours + " hours");
	Ext.get('productlisttotalcost').update(convertCurrency(rec.totalcost, region + "-" + currency));
	Ext.get('details_reoofprimers').update(convertCurrency(rec.reorderingcost, region + "-" + currency));
	Ext.get('details_addmastermix').update(rec.additionalmastermix);
	Ext.get('details_addmastermixcost').update(convertCurrency(rec.additionalmastermixcost, region + "-" + currency));
	Ext.get('details_addlabor').update(convertCurrency(rec.additionallabourcost, region + "-" + currency));
	Ext.get('details_addcost').update(convertCurrency(rec.optimizedcost, region + "-" + currency));
	Ext.get('sybrtotalcost').update(convertCurrency(rec.optimizedcost, region + "-" + currency));
	prepareMailDiscHTML();
}

function hidePopup() {
	Ext.get('popup').removeCls('visible');
	Ext.get('popup').addCls('hidden');
}
// add a new row to the table

function addRow(tblGrid, cellsArray, isTotal) {
	var table = Ext.get(tblGrid).dom;
	var rowCount = table.rows.length;
	var newRow = table.insertRow(rowCount);
	var oCell = null;
	var isFirst = true;
	var isSecond = false;
	for (var i = 0; i < cellsArray.length; i++) {
		oCell = newRow.insertCell(i);
		if (isFirst) {
			isFirst = false;
			oCell.className = "wrap";
			isSecond = true;
		} else if (isSecond) {
			isSecond = false;
			oCell.className = "center";
		}
		if (isTotal) {
			oCell.innerHTML = "<span style='font-weight:bold'>" + cellsArray[i] + "</span>";
		} else {
			if (i == 7) {
				var priceSplit = cellsArray[7];
				//var splitArray = priceSplit.split("$");
				//oCell.innerHTML = "<span>$ " + Math.round(splitArray[1]) + ".00</span>";
				oCell.innerHTML = "<span>" + cellsArray[7] + "</span>";
			} else {
				oCell.innerHTML = "<span>" + cellsArray[i] + "</span>";
			}
		}
	}
}

function showEditDiscPopup(id) {
	var rec = detailspageinfo.findRecord('id', id);
	Ext.get('popvoldisc').update((rec.get('volumediscount') && rec.get('volumediscount') > 0) ? rec.get('volumediscount') : "0");
	Ext.get('discedited').dom.value = rec.get('discount');
	Ext.get('editdiscpopup').addCls('visible');
	Ext.get('editdiscpopup').removeCls('hidden');
	Ext.get('editdiscpopup').dom.style.top = (250+100)+ "px";
	Ext.get('editdiscpopup').dom.style.left = 48 + "%";
	discchgid = id;
	// Ext.get('editdiscsubmit').on('click', function(ev) {
	// ev.preventDefault(); // Prevents the browsers default handling of the
	// event
	// ev.stopPropagation(); // Cancels bubbling of the event
	// ev.stopEvent(); // preventDefault + stopPropagation
	//	 
	// alert('calling submit');
	// discEditedSubmit(id);
	// return false;
	// //Ext.get('editdiscpopup').addCls('hidden');
	// //Ext.get('editdiscpopup').removeCls('visible');
	//
	// });
	Ext.get('editdiscclose').on('click', function () {
		Ext.get('editdiscpopup').addCls('hidden');
		Ext.get('editdiscpopup').removeCls('visible');
	});
	
	//alert('test')
	
	return false;
}

function discEditedSubmit() {
	
	var discount1 = parseFloat(Ext.get('discedited').dom.value);	
	if (isNumber(discount1)) {
		var rec = detailspageinfo.findRecord('id', discchgid, 0, false, false, true);
		
		
		
		var noOfUnits = rec.get('quantity');
		var unitPrice = rec.get('unitprice');
		var netPrice = (noOfUnits * unitPrice) * (1 - (discount1 / 100));
		rec.set('discount', discount1);
		rec.set('volumediscount', discount1);
		rec.set('netprice', netPrice);
		// rec.set('priceperreaction', pricePerReaction);
		// rec.set('pricepersample', pricePerSample);
		var totalPrice = 0;
		clearTable('productdetailstable');
		var reaction = new Array();
		for (var i = 0; i < detailspageinfo.getCount(); i++) {
			var e = detailspageinfo.getAt(i);
			if (e.get('quantity') > 0)
			{
				var count = 0;
				var cellValues = new Array(10);
				reaction[i] = e.get('noofreactions');
				cellValues[count++] = e.get('product');
				cellValues[count++] = e.get('type');
				cellValues[count++] = e.get('noofreactions');
				cellValues[count++] = e.get('partnumber');
				cellValues[count++] = e.get('quantity');
				cellValues[count++] = convertCurrency(roundNumber(e.get('unitprice'), 2), region + "-" + currency);
				cellValues[count++] = e.get('volumediscount2');
				
				var discHtml = "<div><a href='#' onclick='showEditDiscPopup(" + e.get('id') + "); return false;' class='EditTotalDiscount'>Edit</a></div>";
				cellValues[count++] = e.get('discount') + discHtml;
				var pricePerReaction = (e.get('netprice') / (e.get('noofreactions')));
				var pricePerSample = (e.get('netprice') / (getExperimentInfo('noofsamples')));
				cellValues[count++] = convertCurrency((pricePerReaction), region + "-" + currency);
				cellValues[count++] = convertCurrency((pricePerSample), region + "-" + currency);
				cellValues[count++] = convertCurrency(roundNumber(e.get('netprice'), 2), region + "-" + currency);
				totalPrice = totalPrice + e.get('netprice');
				addRow('productdetailstable', cellValues, false);
			}
		}
		Ext.get('totalcost').update(convertCurrency((totalPrice), region + "-" + currency));
		Ext.get('productlisttotalcost').update(convertCurrency((totalPrice), region + "-" + currency));
		if ((rec.get('type') == 'RT') || (rec.get('type') == 'Pre-Amp')) {
			//var pricePerReaction = totalPrice / (reaction[0]);
			var pricePerReaction = totalPrice / (rec.get('noofreactions'));
		} else {
			var pricePerReaction = totalPrice / (rec.get('noofreactions'));
		}
		var pricePerSample = totalPrice / (getExperimentInfo('noofsamples'));
		Ext.get('costperreaction').update(convertCurrency(pricePerReaction, region + "-" + currency));
		Ext.get('costpersample').update(convertCurrency(pricePerSample, region + "-" + currency));
		prepareMailDiscHTML();
	}
	Ext.get('editdiscpopup').addCls('hidden');
	Ext.get('editdiscpopup').removeCls('visible');
	return false;
}

function discSpinnerEditedSubmit(value, type, txtbxpartno, staticdisc) {
	var isCSPCalc = false;
	if(getExperimentInfo("isCustomPlatingCalc")){
		isCSPCalc = true;
	}
	Ext.get('digitalmsg').update("");
	var outputListrec = outputList.findRecord('pno', pnos, 0, false, false, true);
	var prodName = outputListrec.get('format');
	var plateperc = (Ext.get('plateperc').dom.value).split('%')[0];
	var openarrayperc = (Ext.get('openarrayperc').dom.value).split('%')[0];	
	var assayperc = (Ext.get('assayperc').dom.value).split('%')[0];
	var isCPSoamiRNA = getExperimentInfo("isCPSoamiRNA");
	var addDisc = 0;
	if (outputListrec.get('type').indexOf('openarray') != -1) {
		addDisc = openarrayperc;
	} else if (outputListrec.get('type').indexOf('card') != -1 || outputListrec.get('type').indexOf('plate') != -1) {
		addDisc = plateperc;
	} else {
		addDisc = assayperc;
	}
	
		if(isCPSoamiRNA){
			var bOpenArrayDiscount = getOpenArrayDiscoutValue("product", parseFloat(value),prodName, true);
			//OpenArrayDisVal.findRecord("product", prodName);						
		} else {
			var discvalue = 0;
			if(type == "Discount"){ 
				discvalue = parseFloat(Ext.get("Q_"+discchgid).dom.value);
			} else {
				discvalue = parseFloat(value);
			}
			var bOpenArrayDiscount = getOpenArrayDiscoutValue("partnumber", parseFloat(discvalue),txtbxpartno, false);
		}
		//var bOpenArrayDiscount = getOpenArrayDiscoutValue("partnumber", parseFloat(value),txtbxpartno, false);
		var totaldisc =  addDisc;
		if( bOpenArrayDiscount ){
			if(type === "Quatity"){
				if(isCPSoamiRNA){
					var voldisc = getExperimentInfo("cpsDiscountValue");
				} else {
					var voldisc = $("#"+txtbxpartno).html();
				}
				if(voldisc == undefined){
					voldisc = 0;
				}
				voldisc = parseFloat(voldisc) +  parseFloat(addDisc);
				disc = parseFloat(voldisc);
			}else{
				var newdisc = value;
				var disc = Number(staticdisc);
				var voldisc = value;			
				if(addDisc !=0){
					if(voldisc < disc){ 
						voldisc = parseFloat(voldisc) +  parseFloat(addDisc);	
					} else { 
						voldisc = (parseFloat(voldisc)- 2.5) +  parseFloat(addDisc);	
					}
				}
			}
		} else if(isCSPCalc){
			var voldisc = 0;
		} else{
			if(type != "Discount"){ 
				var voldisc = Ext.get(discchgid).dom.value;
			} else { 
				var newdisc = value;	
				var voldisc = Ext.get(discchgid).dom.value; //28-05-2014
			}	
		}
	
	var discount1 = value; 
	var newquantity = value;
	if (isNumber(discount1)) {
		//discount1 = disc; 
		if( !isCSPCalc ){
			discount1 = Ext.get(discchgid).dom.value;		
		} else {
			discount1 = 0;
		}
		newquantity = Ext.get("Q_" + discchgid).dom.value;
		var rec = detailspageinfo.findRecord('id', discchgid, 0, false, false, true);
		//console.log(rec);
		var ExperimentInfoTech = getExperimentInfo("technology");
		rec.set('quantity', newquantity);
		
		var noOfUnits = rec.get('quantity');
		var unitPrice = rec.get('unitprice');
		var netPrice = (noOfUnits * unitPrice) * (1 - (voldisc / 100));
		
		//rec.set('discount', discount1);
		rec.set('discount', voldisc);
		rec.set('volumediscount', discount1);
		rec.set('volumediscount2', disc);
		rec.set('netprice', netPrice);
		
		var is1ML = false;
		var is5ML = false;
		var possible1MLReaction = 0;
		var possible5MLReaction = 0;
		var MMDigNetPrice = 0;
		var mmNoOfReaction = 0;
		var exsitingPricePerReaction = 0;
		var exsitingPricePerSample = 0;
		
		var totalPrice = 0;
		var totalPricePerReaction = 0;
		var totalPricePerSample = 0;
		clearTable('productdetailstable');
		var reaction = new Array();
		var mMCount = 0;
		for (var i = 0; i < detailspageinfo.getCount(); i++) {
			var e = detailspageinfo.getAt(i);
			if (e.get('quantity') >= 0)
			{
			//console.log(e.get('product'));
				var count = 0;
				if( !isCSPCalc ){
					var cellValues = new Array(9); //Madhu asked to remove type column on 09/01/2015
				} else if( isCPSoamiRNA ){
					var cellValues = new Array(7);
				} else {
					var cellValues = new Array(6);
				}
				reaction[i] = e.get('noofreactions');
				var rowTitle = e.get('product');
				
				var viewOtherMMBtn = "";
				var buttonName ='';
				var mmButtonName ='';
				if(rec.get('formattype').indexOf('tube') != -1){
					mmButtonName = 'View other sizes and product flavours';
				} else {
					mmButtonName = 'View More Options';
				}
				var isDrugMetabolism = false;
				if( !isCSPCalc ){
					isDrugMetabolism = false;
					if(mMCount == 0){
						if ( ( (globalFormatName.indexOf('Card') != -1) || (globalFormatName.indexOf('Plate') != -1) || (rec.get('formattype').indexOf('tube') != -1) ) && (rowTitle.indexOf('Mix') != -1 ) && (globalFormatName.indexOf('OpenArray') == -1) ) {
							mMCount ++;						
							viewOtherMMBtn = '<span class="viewParnt" id=""><div id="viewMMParntDiv" class="viewParntDivDetPge viewParntMMPge"></div><button class="viewDet" onclick="ViewOtherMMDetails(\''+globalFormatName+'\',\''+rowTitle+'\',\''+pnos+'\'); return false;">'+mmButtonName+'</button></span>&nbsp;';
						}
					}
				}
				if ( (rowTitle.indexOf('Card') != -1) || (rowTitle.indexOf('Plate') != -1) ){
					buttonName = "View Other Formats";
				} else if ( rowTitle.indexOf('DME') != -1 ){
					isDrugMetabolism = true;
				} else {
					buttonName = "View other sizes and product flavours";
				}
				if(!isDrugMetabolism){
				var viewOtherFormatBtn = '<span class="viewParnt" id=""><div id="viewParntDiv" class="viewParntDivDetPge"></div><button class="viewDet" value="viewDetailCont_viewParntDiv_'+pnos+'" onclick="ViewDetails(\''+rowTitle+'\',this, \''+e.get('formattype')+'\'); return false;">'+buttonName+'</button></span>&nbsp;';
				}
				
				if ( ((rowTitle.indexOf('Card') != -1) || (rowTitle.indexOf('Plate') != -1) || (e.get('formattype') == 'tube')) && (getExperimentInfo("type") != "Mutation Detection") && (rowTitle.indexOf('Mix') == -1 ) && (globalFormatName.indexOf('OpenArray') == -1)) {
					if(rowTitle.indexOf('SNP') > -1 ){
						cellValues[count++] = e.get('product')+"*" + viewOtherFormatBtn;
					} else if( isCSPCalc ){ 
						cellValues[count++] = e.get('product');
					} else {
						cellValues[count++] = e.get('product')+ viewOtherFormatBtn;
					}
				}else {
					if(rowTitle.indexOf('SNP') > -1){
						cellValues[count++] = e.get('product')+"*";
					} else if( isCSPCalc ){ 
						cellValues[count++] = e.get('product');
					} else {
						cellValues[count++] = e.get('product') + viewOtherMMBtn;
					}
				}
				//cellValues[count++] = e.get('type'); Madhu asked to remove type column on 09/01/2015
				cellValues[count++] = e.get('noofreactions');
				cellValues[count++] = e.get('partnumber');
				var part_no = e.get('partnumber');
				
				//cellValues[count++] = e.get('quantity');
				
				
				//cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalQuantitySpinner' id='Q_"+e.get('id')+"' name='Q_"+e.get('id')+"' value ='"+ e.get('quantity') +"' partno='"+e.get('partnumber')+"'  >";
				cellValues[count++] = "<input class = 'EditTotalQuantitySpinner Spinner' onkeyup='updatePriceChange(this);' maxlength='3'  id='Q_"+e.get('id')+"' name='Q_"+e.get('id')+"' value ='"+ e.get('quantity') +"' partno='"+e.get('partnumber')+"'  >";
				
				cellValues[count++] = convertCurrency(roundNumber(e.get('unitprice'), 2), region + "-" + currency);
				
				/*if( region == "EMEA" || region == "emea"){
					if( !isCSPCalc ){
						cellValues[count++] = "<span !id='"+e.get('partnumber')+"'>0</span>";
					
						var discHtml = "<div><a href='#' onclick='showEditDiscPopup(" + e.get('id') + "); return false;' class='EditTotalDiscount'>Edit</a></div>";
						cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' id='" + e.get('id') + "' name='" + e.get('id') + "' value ='0' partno='"+e.get('partnumber')+"'>";				
					}
				} else {*/
				
					if( !isCSPCalc || isCPSoamiRNA){
						if(isCPSoamiRNA){
							var seldisCountObj = OpenArrayDisVal.findRecord("product", rowTitle);
						} else {
							var seldisCountObj = OpenArrayDisVal.findRecord("partnumber", e.get('partnumber'));
						}
						if( seldisCountObj != null){
							var discountObj = seldisCountObj.discounts();
							cellValues[count++] = '<div class="prodConfigViewFormat quantValParnt" id="popQuantVal" style="display: none;z-index:999999999999"></div><span id='+e.get('partnumber')+' >'+e.get('volumediscount2')+'</span><img src="images/info.png" alt="Volume Discount" onmouseover="DisplayVolDiscount(this,'+e.get('partnumber')+',\''+rowTitle+'\');"/>';	
							if( !isCSPCalc && !isCPSoamiRNA ) {
								cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='" + e.get('id') + "' name='" + e.get('id') + "' value ='"+  e.get('discount')+"' partno='"+e.get('partnumber')+"'>";
							}
						} else {
							cellValues[count++] = "<span id='"+e.get('partnumber')+"'>"+e.get('volumediscount2')+"</span>";
							if( !isCSPCalc && !isCPSoamiRNA ) {
								cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='" + e.get('id') + "' name='" + e.get('id') + "' value ='"+  e.get('discount')+"' partno='"+e.get('partnumber')+"'>";
							}
							//cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='" + e.get('id') + "' name='" + e.get('id') + "' value ='"+  e.get('discount')+"' partno='"+e.get('partnumber')+"'>";
						}
					}
				//}
				
				/*if( isCPSoamiRNA ){
					cellValues[count++] = "<span id='"+e.get('partnumber')+"'>"+e.get('volumediscount2')+"</span>";
				} else if( !isCSPCalc ) {
					cellValues[count++] = "<span id='"+e.get('partnumber')+"'>"+e.get('volumediscount2')+"</span>";					
					cellValues[count++] = "<input class = 'input_tablespinner pgxspinner EditTotalDiscountSpinner Spinner' onkeyup='updatePriceChange(this);' id='" + e.get('id') + "' name='" + e.get('id') + "' value ='"+  e.get('discount')+"' partno='"+e.get('partnumber')+"'>";				
				}*/
				
				if(rowTitle.indexOf('3D Digital PCR Chips') > 0){
					var netPrice = e.get('netprice');
					var noofrxns = e.get('noofreactions');
					var pricePerReaction = netPrice * (noofrxns/(e.get('quantity')*12));					
					pricePerReaction = pricePerReaction/noofrxns;					
					var pricepersample = netPrice * (noofrxns/(e.get('quantity')*12));
					pricepersample = pricepersample/getExperimentInfo('noofsamples');
					if( !isCSPCalc ){
						cellValues[count++] = convertCurrency(pricePerReaction, region + "-" + currency);
						cellValues[count++] = convertCurrency(pricepersample, region + "-" + currency);
					}
					totalPricePerReaction = totalPricePerReaction + pricePerReaction;
					totalPricePerSample = totalPricePerSample + pricepersample;
					exsitingPricePerReaction = exsitingPricePerReaction + pricePerReaction;
					exsitingPricePerSample = exsitingPricePerSample + pricepersample;
				} else if(rowTitle.indexOf('Copy Number Reference Assay') > 0){
					var netPrice = e.get('netprice');
					var noofrxns = e.get('noofreactions');
					var pricePerReaction = netPrice * (noofrxns/(e.get('quantity')*e.get('refassayreaction')));					
					pricePerReaction = pricePerReaction/noofrxns;					
					var pricepersample = netPrice * (noofrxns/(e.get('quantity')*e.get('refassayreaction')));
					pricepersample = pricepersample/getExperimentInfo('noofsamples');
					if( !isCSPCalc ){
						cellValues[count++] = convertCurrency(pricePerReaction, region + "-" + currency);
						cellValues[count++] = convertCurrency(pricepersample, region + "-" + currency);
					}
					totalPricePerReaction = totalPricePerReaction + pricePerReaction;
					totalPricePerSample = totalPricePerSample + pricepersample;
					exsitingPricePerReaction = exsitingPricePerReaction + pricePerReaction;
					exsitingPricePerSample = exsitingPricePerSample + pricepersample;
				} else if(rowTitle.indexOf('Digital PCR UV Sealing Kit') > 0){
					var netPrice = e.get('netprice');
					var noofrxns = e.get('noofreactions');
					var UvChipsEffectNetPrice = netPrice * (noofrxns/ (e.get('quantity') * 100)) ; 
					var UvChipsCostPerReaction = UvChipsEffectNetPrice / noofrxns;
					var uvCostPerSample = netPrice * (noofrxns/(e.get('quantity') * 100));		
					uvCostPerSample = uvCostPerSample/getExperimentInfo('noofsamples');
					if( !isCSPCalc ){
						cellValues[count++] = convertCurrency(UvChipsCostPerReaction, region + "-" + currency);
						cellValues[count++] = convertCurrency(uvCostPerSample, region + "-" + currency);
					}
					totalPricePerReaction = totalPricePerReaction + UvChipsCostPerReaction;
					totalPricePerSample = totalPricePerSample + uvCostPerSample;
					exsitingPricePerReaction = exsitingPricePerReaction + UvChipsCostPerReaction;
					exsitingPricePerSample = exsitingPricePerSample + uvCostPerSample;
				} else if(rowTitle.indexOf('Digital PCR Master Mix (5mL)') > 0){
					var displaypriceperrxn = e.get('displaypriceperrxn');
					var netPrice = e.get('netprice');
					var noofrxns = e.get('noofreactions');
					possible5MLReaction = e.get('quantity') * 384;					
					var pricepersample = netPrice * (noofrxns/possible5MLReaction);
					pricepersample = pricepersample/getExperimentInfo('noofsamples');					
					var pricePerReaction = netPrice *(noofrxns/possible5MLReaction); 		
					pricePerReaction = pricePerReaction/noofrxns;	
					/*if(e.get('mnoofunits') > 0){
						var priceperrxn = (e.get('netprice') + e.get('mastermixcostwithdisc')) / e.get('noofreactions');
						cellValues[count++] = convertCurrency(priceperrxn, region + "-" + currency);
						totalPricePerReaction = totalPricePerReaction + priceperrxn;
						var combinationpricepersample = (e.get('netprice') + e.get('mastermixcostwithdisc')) / getExperimentInfo('noofsamples');
						cellValues[count++] = convertCurrency((combinationpricepersample), region + "-" + currency);
						totalPricePerSample = totalPricePerSample + combinationpricepersample;
					} else { */
						if( !isCSPCalc ){
							cellValues[count++] = '<span id = "digital_PR_5ML">'+  convertCurrency(pricePerReaction, region + "-" + currency)  + '<span>';
							totalPricePerReaction = totalPricePerReaction + pricePerReaction;
							cellValues[count++] = '<span id = "digital_PS_5ML">'+convertCurrency((pricepersample), region + "-" + currency)+'</span>';
							totalPricePerSample = totalPricePerSample + pricepersample;
						}
						
						MMDigNetPrice = MMDigNetPrice + netPrice;
						is5ML = true
						mmNoOfReaction = e.get('noofreactions');
					//}
					//cellValues[count++] = convertCurrency((discountedUnitprice/384), region + "-" + currency);
					
				} else if(rowTitle.indexOf('Digital PCR Master Mix (1.5mL)') > 0){
					var displaypriceperrxn = e.get('displaypriceperrxn');
					var netPrice = e.get('netprice');
					var noofrxns = e.get('noofreactions');
					possible1MLReaction = e.get('quantity') * 96;
					
					var pricepersample = netPrice * (noofrxns/possible1MLReaction);
					pricepersample = pricepersample/ getExperimentInfo('noofsamples');
					var pricePerReaction = netPrice *(noofrxns/possible1MLReaction); 		
					pricePerReaction = pricePerReaction/noofrxns;					
					/*if(!displaypriceperrxn){
						var priceperrxn = (e.get('netprice') + e.get('mastermixcostwithdisc1')) / e.get('noofreactions');
						cellValues[count++] = convertCurrency(priceperrxn, region + "-" + currency);
						totalPricePerReaction = totalPricePerReaction + priceperrxn;
						var combinationpricepersample = (e.get('netprice') + e.get('mastermixcostwithdisc1')) / getExperimentInfo('noofsamples');
						cellValues[count++] = convertCurrency((combinationpricepersample), region + "-" + currency);
						totalPricePerSample = totalPricePerSample + combinationpricepersample;
					} else {*/
					if( !isCSPCalc ){
						cellValues[count++] = '<span id = "digital_PR_1ML">'+  convertCurrency(pricePerReaction, region + "-" + currency)  + '<span>';
						totalPricePerReaction = totalPricePerReaction + pricePerReaction;	
						cellValues[count++] = '<span id = "digital_PS_1ML">'+ convertCurrency((pricepersample), region + "-" + currency) + '<span>';
						totalPricePerSample = totalPricePerSample + pricepersample
					}
						MMDigNetPrice = MMDigNetPrice + netPrice;	
						is1ML = true;
						mmNoOfReaction = e.get('noofreactions');						
					//}
					//cellValues[count++] = convertCurrency((discountedUnitprice/96), region + "-" + currency);
					
				} else if(rowTitle.indexOf('Gene') > -1 && getExperimentInfo("isDigitalPCR") === "true"){
					var netPrice = e.get('netprice');
					var noofrxns = e.get('noofreactions');
					var pricePerReaction = netPrice * (noofrxns/(e.get('quantity') * e.get('tubenoofreactions')));					
					pricePerReaction = pricePerReaction/noofrxns;						
					var pricepersample = netPrice * (noofrxns/(e.get('quantity') * e.get('tubenoofreactions')));
					pricepersample = pricepersample/getExperimentInfo('noofsamples');
					if( !isCSPCalc ){
						cellValues[count++] = convertCurrency(pricePerReaction, region + "-" + currency);
						cellValues[count++] = convertCurrency(pricepersample, region + "-" + currency);
					}
					totalPricePerReaction = totalPricePerReaction + pricePerReaction;
					totalPricePerSample = totalPricePerSample + pricepersample;
					exsitingPricePerReaction = exsitingPricePerReaction + pricePerReaction;
					exsitingPricePerSample = exsitingPricePerSample + pricepersample;
				}  else if(ExperimentInfoTech == "DigitalPCR" && rowTitle.indexOf('SNP') > -1){
					var netPrice = e.get('netprice');
					var noofrxns = e.get('noofreactions');
					var pricePerReaction = netPrice * (noofrxns/(e.get('quantity') * e.get('tubenoofreactions')));					
					pricePerReaction = pricePerReaction/noofrxns;	
					var pricepersample = netPrice * (noofrxns/(e.get('quantity') * e.get('tubenoofreactions')));
					pricepersample = pricepersample/getExperimentInfo('noofsamples');
					if( !isCSPCalc ){
						cellValues[count++] = convertCurrency(pricePerReaction, region + "-" + currency);
						cellValues[count++] = convertCurrency(pricepersample, region + "-" + currency);
					}
					totalPricePerReaction = totalPricePerReaction + pricePerReaction;
					totalPricePerSample = totalPricePerSample + pricepersample;
					exsitingPricePerReaction = exsitingPricePerReaction + pricePerReaction;
					exsitingPricePerSample = exsitingPricePerSample + pricepersample;
				} else if(rowTitle.indexOf('Copy Number,Custom assays') > 0){
					var netPrice = e.get('netprice');
					var noofrxns = e.get('noofreactions');
					var pricePerReaction = netPrice * (noofrxns/(e.get('quantity')*e.get('tubenoofreactions')));					
					pricePerReaction = pricePerReaction/noofrxns;					
					var pricepersample = netPrice * (noofrxns/(e.get('quantity')*e.get('tubenoofreactions')));
					pricepersample = pricepersample/getExperimentInfo('noofsamples');
					if( !isCSPCalc ){
						cellValues[count++] = convertCurrency(pricePerReaction, region + "-" + currency);
						cellValues[count++] = convertCurrency(pricepersample, region + "-" + currency);
					}
					totalPricePerReaction = totalPricePerReaction + pricePerReaction;
					totalPricePerSample = totalPricePerSample + pricepersample;
					exsitingPricePerReaction = exsitingPricePerReaction + pricePerReaction;
					exsitingPricePerSample = exsitingPricePerSample + pricepersample;
				} else { 
					//console.log(e.get('netprice') +"/"+ (e.get('noofreactions')));
					var pricePerReaction = (e.get('netprice') / (e.get('noofreactions')));
					//console.log(pricePerReaction);
					var pricePerSample = (e.get('netprice') / (getExperimentInfo('noofsamples')));
					if( !isCSPCalc ){
						cellValues[count++] = convertCurrency((pricePerReaction), region + "-" + currency);
						cellValues[count++] = convertCurrency((pricePerSample), region + "-" + currency);
					}
					totalPricePerReaction = totalPricePerReaction + (e.get('netprice') / (e.get('noofreactions')));
					totalPricePerSample = totalPricePerSample + (e.get('netprice') / (getExperimentInfo('noofsamples')));
					
					exsitingPricePerReaction = exsitingPricePerReaction + pricePerReaction;
					exsitingPricePerSample = exsitingPricePerSample + pricePerSample;
				}
				//cellValues[count++] = convertCurrency((e.get('priceperreaction')), region + "-" + currency);
				//cellValues[count++] = convertCurrency((e.get('pricepersample')), region + "-" + currency);
				cellValues[count++] = convertCurrency(roundNumber(e.get('netprice'), 2), region + "-" + currency);
				totalPrice = totalPrice + e.get('netprice');
				addRow('productdetailstable', cellValues, false);
				$("#"+txtbxpartno).html(disc);				
			} 
		}
		if( is1ML && is5ML){
			var pricePerSample = MMDigNetPrice / (mmNoOfReaction /(possible1MLReaction + possible5MLReaction) );
			pricePerSample = pricePerSample / getExperimentInfo('noofsamples');
				
			var pricePerReaction = MMDigNetPrice * (mmNoOfReaction /(possible1MLReaction + possible5MLReaction)  ); 		
			pricePerReaction = pricePerReaction/mmNoOfReaction;
			
			exsitingPricePerReaction = exsitingPricePerReaction + pricePerReaction;
			exsitingPricePerSample = exsitingPricePerSample + pricePerSample;
					
			Ext.get('digital_PS_1ML').update(convertCurrency((pricePerSample), region + "-" + currency));
			Ext.get('digital_PS_5ML').update(convertCurrency((pricePerSample), region + "-" + currency));
			
			Ext.get('digital_PR_1ML').update(convertCurrency((pricePerReaction), region + "-" + currency));
			Ext.get('digital_PR_5ML').update(convertCurrency((pricePerReaction), region + "-" + currency));
			
		}
		
		Ext.get('totalcost').update(convertCurrency((totalPrice), region + "-" + currency));
		Ext.get('productlisttotalcost').update(convertCurrency((totalPrice), region + "-" + currency));
		if ((rec.get('type') == 'RT') || (rec.get('type') == 'Pre-Amp')) {
			//var pricePerReaction = totalPrice / (reaction[0]);
			var pricePerReaction = totalPrice / (rec.get('noofreactions'));
			var pricePerSampleTotal = totalPrice / (getExperimentInfo('noofsamples'));
		} else if(rec.get('product').indexOf('Digital PCR') > 0 && ( !is1ML || !is5ML ) ){
			var pricePerReaction = totalPricePerReaction; 
			var pricePerSampleTotal = totalPricePerSample;
		} else if(is1ML && is5ML){
			var pricePerReaction = exsitingPricePerReaction; 
			var pricePerSampleTotal = exsitingPricePerSample;
		} else {
			var pricePerReaction = totalPrice / (rec.get('noofreactions'));
			var pricePerSampleTotal = totalPrice / (getExperimentInfo('noofsamples'));
		}
		
		
		Ext.get('costperreaction').update(convertCurrency(pricePerReaction, region + "-" + currency));
		Ext.get('costpersample').update(convertCurrency(pricePerSampleTotal, region + "-" + currency));
		if(rec.get('product').indexOf('Digital PCR') > 0){
			Ext.get('digitalmsg').update("* Indicates the cost for exact quantity used.");
		} else {
			Ext.get('digitalmsg').update("");
		}
		//createSpinner();
		prepareMailDiscHTML();

		if(type === "Quatity"){
			var input = $("#Q_"+discchgid);
			var len = input.val().length;
			input[0].focus();
			input[0].setSelectionRange(len, len);
		}else if(type === "Discount"){
			var input = $("#"+discchgid);
			var len = input.val().length;
			input[0].focus();
			input[0].setSelectionRange(len, len);
		}
		
	}
	return false;
}

function clearTable(tblGrid) {
	var table = Ext.get(tblGrid).dom;
	var rowCount = table.rows.length;
	for (var i = 1; i < rowCount; i++) {
		removeRow(tblGrid, 1);
	}
}
// deletes the specified row from the table

function removeRow(tblGrid, rowIndex) {
	Ext.get(tblGrid).dom.deleteRow(rowIndex);
}
function createSpinner(){	
	/* commented on 21/01/2015 Lini asked to remove spinner
	$( ".EditTotalDiscountSpinner" ).spinner({ min: 0, max: 100, step: 2.5});
		
	//$( ".EditTotalDiscountSpinner" ).spinner({ min: 0, max: 100, step: 0.1});
	
	$( ".EditTotalQuantitySpinner" ).spinner({min: 0, step: 1});
	
	$( ".EditTotalQuantitySpinner" ).on('click', function(){
			$("#"+this.id).focus();
	});
	
	$( ".EditTotalDiscountSpinner" ).on('click', function(){
			$("#"+this.id).focus();
	});*/
	//setMinimumQtyForSpinner(); //activated this functionality on 19-06-2014 on request by Lini
	//toactivateSpinner(); 
}

function toactivateSpinner(){
	$('.ui-spinner-button').click(function() {                       
		$(this).siblings('input').change();
	});
	
	$('.EditTotalQuantitySpinner').spinner().change(function(){
			var d_id = (this.id).split("_")[1]; 
			var rec = detailspageinfo.findRecord('id', d_id, 0, false, false, true);
			var txtbxpartno = this.getAttribute('partno');
			discchgid = d_id; 
			discSpinnerEditedSubmit($(this).spinner('value'), "Quatity", txtbxpartno, '');
     });
	 $( ".EditTotalQuantitySpinner" ).on('keyup', function(e){
		 if(e.which != 37 && e.which != 39){
			var d_id = (this.id).split("_")[1];
			var rec = detailspageinfo.findRecord('id', d_id, 0, false, false, true);
			discchgid = d_id; 
			var txtbxpartno = this.getAttribute('partno');
			discSpinnerEditedSubmit($(this).spinner('value'), "Quatity", txtbxpartno, '');			
		 }
	});

	$('.EditTotalDiscountSpinner').spinner().change(function(){
			discchgid = this.id;
			var txtbxpartno = this.getAttribute('partno');
			var staticdisc = Number($("#"+txtbxpartno).html());
			discSpinnerEditedSubmit($(this).spinner('value'), "Discount", txtbxpartno, staticdisc);
     });
	 
	 $('.EditTotalDiscountSpinner').on('keyup', function(e){
			discchgid = this.id;
			var txtbxpartno = this.getAttribute('partno');
			var staticdisc = Number($("#"+txtbxpartno).html());
			discSpinnerEditedSubmit($(this).val(), "Discount", txtbxpartno, staticdisc);
     });
	 
	 
	 //copyMinQtyfromDetailsInfo();
	 //setMinimumQtyForSpinner();
}

// Replace for spinner on 21/01/2015
function updatePriceChange(obj){
	var length = (obj.id.split('_')).length;
	if( length >= 2 ){
		discchgid = obj.id.split('_')[1];
	}else{
		discchgid = obj.id;
	}
	var type = "";
	type = "Discount";
	var txtbxpartno = obj.getAttribute('partno');
	if( (obj.id).indexOf('Q') != -1 ){
		type = "Quatity";
	} else { 
		if(discchgid == 0){
			console.log()
			var outputListrec = detailspageinfo.findRecord('id', discchgid, 0, false, false, true);			
			var updatedVolDis = outputListrec.get('volumediscount2');
			//var updatedVolDis = getExperimentInfo("detailsDiscountValue");
			
			if( updatedVolDis < Number($(obj).val())){				
				$("#overlay").show();
				$("#DiscountMsg").show();
				var volDiscMsg = '';
				volDiscMsg = volDiscMsg + '<div class="viewDetailCont viewQuant">';	
				volDiscMsg = volDiscMsg + '		<div class="ivgnModal-close quant-close">';
				volDiscMsg = volDiscMsg + '<span style="display: inline-block;margin-top: 10px; color: red;font-size: 15px;">Note:</span>';
				volDiscMsg = volDiscMsg + '<a class="" href="javascript:void(0);" rel=" " onclick="closeVolDiscountMsg();"><span class="closeTxt">CLOSE</span> <b class="clSym">&#215</b></a></div>';
				volDiscMsg = volDiscMsg + '<div class="viewTableParnt" style="padding-top: 30px;text-align: justify; line-height: 20px;">';
				volDiscMsg = volDiscMsg + 'The discount entered is above the recommended level for this volume.  As a result, this order may not be profitable.  Please consult with your sales leader or product management before using this discount.';
				volDiscMsg = volDiscMsg + '		</div>';
				volDiscMsg = volDiscMsg + '</div>';
				$("#DiscountMsg").html(volDiscMsg);				
			} 
		}
		
	}
	if(parseInt($(obj).val()) < 0 || isNaN($(obj).val())) 
        $(obj).val(0);
    else if(parseInt($(obj).val()) > 1000) 
        $(obj).val(1000); 
		
	updateExperimentInfo("detailsInputType", type);
	var staticdisc = Number($("#"+txtbxpartno).html());
	discSpinnerEditedSubmit($(obj).val(), type, txtbxpartno, staticdisc);
}

function closeVolDiscountMsg(){
	$("#DiscountMsg").html('');
	$("#DiscountMsg").hide();
	$("#overlay").hide().css('z-index','99999999');
	$("body").css('overflow','auto');
}

//To copy the details info store to minimum qty store.
function copyMinQtyfromDetailsInfo(){
	for (var i = 0; i < detailspageinfo.getCount(); i++) {
		var e = detailspageinfo.getAt(i);
		if (e.get('quantity') >= 0 ){
			minqtydetailsinfo.push({ "id": e.get('id'),"quantity":  e.get('quantity'),"discount": e.get('discount'),"ismin": e.get('ismin'), "min": e.get('min')});
		}
	}
		
}

//To set the minimum value for quatity spinner.
function setMinimumQtyForSpinner(){
	for (var i = 0; i < minqtydetailsinfo.length; i++) {
		if (minqtydetailsinfo[i]['quantity'] >= 0 && minqtydetailsinfo[i]['min'] > 0 ){
			$( "#Q_"+minqtydetailsinfo[i]['id'] ).spinner({ min: minqtydetailsinfo[i]['min'], max: 10000});
		}
		/*if (minqtydetailsinfo[i]['quantity'] >= 0){
			$( "#Q_"+minqtydetailsinfo[i]['id'] ).spinner({ min: minqtydetailsinfo[i]['quantity'], max: 10000});
		}*/
	}

}

function checkMinQty(id, value){
	for (var i = 0; i < minqtydetailsinfo.length; i++) {
		if (minqtydetailsinfo[i]['id'] ===  id){ 
			if (value >= minqtydetailsinfo[i]['quantity'] ){ 
				return true;
			}else{ 
				return false;
			}
		}
		
	}
}

function DisplayVolDiscount(obj,PartNo,rowTitle){
	$("#popQuantVal").show();
	$("#overlay").show();
	var isCPSoamiRNA = getExperimentInfo("isCPSoamiRNA");
	if(isCPSoamiRNA){
		var seldisCountObj = OpenArrayDisVal.findRecord("product", rowTitle);
	} else {
		var selectedRegion = '';
		var seldisCountObj;
		if( region == "EMEA" || region == "emea"){
			selectedRegion = "EMEA";
		} else {
			selectedRegion = "ALL";
		}
		
		OpenArrayDisVal.each(function (e) {
		   if( e.get("partnumber") == PartNo && e.get("region") == selectedRegion ){
			   seldisCountObj = e;
			}

		});
		//var seldisCountObj = OpenArrayDisVal.findRecord("partnumber", PartNo);
	}
	//var seldisCountObj = OpenArrayDisVal.findRecord("partnumber", PartNo);
	if( seldisCountObj != null){
		var discountObj = seldisCountObj.discounts();
		var LoopCount = 1;
		var qtyTable = '';
		qtyTable = qtyTable + '<div class="viewDetailCont viewQuant">';	
		qtyTable = qtyTable + '		<div class="ivgnModal-close quant-close"><a class="" href="javascript:void(0);" rel=" " onclick="closeVolDiscount();"><span class="closeTxt">CLOSE</span> <b class="clSym">&#215</b></a></div>';
		qtyTable = qtyTable + '		<div class="viewTableParnt">';
		qtyTable = qtyTable + '			<table>';
		qtyTable = qtyTable + '				<thead>';
		qtyTable = qtyTable + '					<tr class="tbhead">';
		qtyTable = qtyTable + '						<th> Quantity';
		qtyTable = qtyTable + '						</th>';
		qtyTable = qtyTable + '						<th> Discount Value';
		qtyTable = qtyTable + '						</th>';
		qtyTable = qtyTable + '					</tr>';
		qtyTable = qtyTable + '				</thead>';
		qtyTable = qtyTable + '				<tbody>';
		discountObj.each(function (e) {
			if (discountObj.count() == LoopCount) {
				  var QtyVal = " &#8805; "+e.get("qty");				  
			 } else {
				  var qtyCheck = (e.get("qty")).split("-");
				  if( qtyCheck[0] == qtyCheck[1] ){
					  var QtyVal = qtyCheck[0];
				  } else {
					  var QtyVal = e.get("qty");
				  }
				 
			 }
			var DiscVal = e.get("discval")+" %";
			qtyTable = qtyTable + '					<tr>';
			qtyTable = qtyTable + '						<td style="text-align: center;">'+QtyVal+'</td>';
			qtyTable = qtyTable + '						<td style="text-align: center;">'+DiscVal+'</td>';
			qtyTable = qtyTable + '					</tr>';
			LoopCount++;
		});
		qtyTable = qtyTable + '				</tbody>';
		qtyTable = qtyTable + '			</table>';
		qtyTable = qtyTable + '		</div>';
		qtyTable = qtyTable + '</div>';
		
		$("#popQuantVal").html(qtyTable);
	} else {
		console.log('false');
	}
}

function closeVolDiscount(){
	$("#popQuantVal").html('');
	$("#popQuantVal").hide();
	$("#overlay").hide().css('z-index','99999999');
	$("body").css('overflow','auto');
}



function changeTotalDiscount(obj,PartNo,rowTitle){ 
	
	var selectedRegion = '';
	var seldisCountObj;
	if( region == "EMEA" || region == "emea"){
		selectedRegion = "EMEA";
	} else {
		selectedRegion = "ALL";
	}
	
	OpenArrayDisVal.each(function (e) {
	   if( e.get("partnumber") == PartNo && e.get("region") == selectedRegion ){
		   seldisCountObj = e;
		}

	});		
	
	if( seldisCountObj != null){
		var discountObj = seldisCountObj.discounts();
		var LoopCount = 1;
		
		discountObj.each(function (e) {			
			if(e.get("discval") > Number($(obj).val())){	
				return false;
				alert('The discount entered is below the recommended level for this volume.  As a result, this order may not be profitable.  Please consult with your sales leader or product management before using this discount.');	
				console.log('The discount entered is below the recommended level for this volume.  As a result, this order may not be profitable.  Please consult with your sales leader or product management before using this discount.');
				
			} else {
				alert('false');
			}
			LoopCount++;
		});
		
		updatePriceChange(obj); 
	} else {
		console.log('false');
	}
}