var dnaexttotal =0;
var snpcnvintrumentstotal =0;
var snpintrumentstotal =0;
var cnvintrumentstotal =0;
var consureagtotal =0;
var MagMAXConstotal =0;
var MagMAXReagtotal =0;
var SNPconsumtotal =0;
var SNPreagtotal =0;
var CNVconsumtotal =0;
var CNVreagtotal =0;

function stratPGxSecondStep(){ 
	
	
	//Ext.get('PGxProcess').removeCls('hidden');
	//Ext.get('PGxProcess').addCls('visible');
	
	createPGxSpinner();
	
	pgxsamplecomboxoption('pgxsamplecombobox','','');
	pgxsamplecomboxoption('pgxsnpopenarrayformat','','');
	pgxsamplecomboxoption('pgxcnainstruments','','');
	pgxsamplecomboxoption('pgxintallation_installneed','', '');
	pgxsamplecomboxoption('pgxintallation_maintenance','','');
	pgxsamplecomboxoption('pgxintallation_addtraining','', '');
	pgxsamplecomboxoption('pgx_delivery_methodcombo','', '');
	pgxsamplecomboxoption('pgxsnpformatneed','', 'ALL');
	pgxsamplecomboxoption('pgxcnainstrumentsneedtouse','', '');
	pgxsamplecomboxoption('pgxsnpassaytype','', '');
	pgxsamplecomboxoption('pgxcnvassaytype','', '');

	Ext.get('no_of_pgxsamples').on('keyup', function (e) {
		var pgxsamples = Ext.get('no_of_pgxsamples').dom.value;
		if (pgxsamples == 0) {
			var pgxsamples = 1;
		}
		if (isNumber(pgxsamples)) {
			calcforPGXInputs();
		}
	});
	Ext.get('pgxsamplecombobox').on('change', function (e) {
		calcforPGXInputs();
	});
	Ext.get('pgxsnpopenarrayformat').on('change', function (e) {
		var pgxopenarraycalctypeobj = Ext.get("pgxsnpopenarrayformat").dom;
		var selectpgxopenarrayObjValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
		pgxsamplecomboxoption('pgxsnpformatneed','', selectpgxopenarrayObjValue);
		
		var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
		var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
		
		if(selectpgxsnpopenarrayInstValue.indexOf("OpenArray") == 0 ){					
			 $('[name=pgxcnainstrumentsneedtouse]').val('384-well');
			  $("#assaytype").hide();
			  Ext.get('pgxsnpreplicates').dom.value = 2;
		} else {
			Ext.get('pgxsnpreplicates').dom.value = 1;
			 $("#assaytype").show();
		}
		calcforPGXInputs();
	});
	checkSNPformat();
	Ext.get('pgxsnpformatneed').on('change', function (e) {
		
		var pgxcnainstrumentsobj = Ext.get("pgxcnainstruments").dom;
		var pgxcnainstrumentsValue = pgxcnainstrumentsobj.options[pgxcnainstrumentsobj.selectedIndex].value;
		if(pgxcnainstrumentsValue.indexOf("Same") == 0 ){					
			 //$('[name=pgxcnainstruments]').val('QuantStudio 12K');
			 $("#howmanysnpinstneed").html('How many instruments or blocks do you need?');
			// Ext.get('pgxcnanoofinstruments').dom.value = Ext.get('pgxsnpqsoavalue').dom.value;
		} else {
			$("#howmanysnpinstneed").html('How many instruments do you need?');
			//Ext.get('pgxcnanoofinstruments').dom.value = Ext.get('recommended_cnvpgxinstruments').dom.value;
		}
		
		var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
		var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
		
		if(selectpgxsnpopenarrayInstValue.indexOf("OpenArray") == 0 ){					
			 $('[name=pgxcnainstrumentsneedtouse]').val('384-well');
			  $("#assaytype").hide();
			  Ext.get('pgxsnpreplicates').dom.value = 2;
		} else {
			Ext.get('pgxsnpreplicates').dom.value = 1;
			 $("#assaytype").show();
		}
		calcforPGXInputs();
	});
	
	Ext.get('pgxsnpreplicates').on('keyup', function (e){
		calcforPGXInputs();
		//if (isNumber(pgxsnpsample)) {
			//Ext.get('use_of_snppgxinstruments').dom.value = Math.round((((Ext.get("hdpgxsampleval").dom.value / Ext.get('max_snpsample_per_year').dom.value) * Ext.get('pgxsnpreplicates').dom.value) * 100 ), 5);
		//}			
	});
	
	//calcforPGXInputs();
	Ext.get('pgxsnpsample').on('keyup', function (e) {
		var pgxsnpsample = Ext.get('pgxsnpsample').dom.value;
		if (pgxsnpsample == 0) {
			var pgxsnpsample = 1;
		}
		if (isNumber(pgxsnpsample)) {
			calcforPGXInputs();
		}
	});
	
	Ext.get('pgxcnasample').on('keyup', function (e) {
		var pgxcnvsamples = Ext.get('pgxcnasample').dom.value;
		if (pgxcnvsamples == 0) {
			var pgxcnvsamples = 1;
		}
		if (isNumber(pgxcnvsamples)) {
			calcforPGXInputs();
			//calcforPGXCnvInputs();
		}
	});

	Ext.get('pgxcnainstruments').on('change', function (e) {
		calcforPGXInputs();
		var pgxcnainstrumentsobj = Ext.get("pgxcnainstruments").dom;
		var pgxcnainstrumentsValue = pgxcnainstrumentsobj.options[pgxcnainstrumentsobj.selectedIndex].value;
		if(pgxcnainstrumentsValue.indexOf("Same") == 0 ){	
			//Ext.get('pgxcnanoofinstruments').dom.value = Ext.get('pgxsnpqsoavalue').dom.value;
			 $("#howmanysnpinstneed").html('How many instruments or blocks do you need?');
			 calcforPGXInputs();
		} else {
			$("#howmanysnpinstneed").html('How many instruments do you need?');
			calcforPGXInputs();
			//Ext.get('pgxcnanoofinstruments').dom.value = Ext.get('recommended_cnvpgxinstruments').dom.value;
		}
	});
	Ext.get('pgxcnainstrumentsneedtouse').on('change', function (e) {
		e.preventDefault();
		/*if(!isValidIstrumrntsforPGX()){
			alert("Please enter the necessary input values.");
		}else{
			calcforPGXInputs();
		}*/
		var PGxreturnval = isValidIstrumrntsforPGX();
		if(PGxreturnval == true){
			calcforPGXInputs();
			//calcforPGXCnvInputs();
			//Ext.get('pgxcnanoofinstruments').dom.value = Ext.get('recommended_cnvpgxinstruments').dom.value;
		} else {
			alert(PGxreturnval);
		}
	});

	Ext.get('pgxcnanoofinstruments').on('keyup', function (e) {
		var pgxcnvinstruments = Ext.get('pgxcnanoofinstruments').dom.value;
		if (isNumber(pgxcnvinstruments)) {
			//calcforPGXInputs();
			//calcforPGXCnvInputs();
		}
	});
	
	Ext.get('delayjsonloading').addCls('dispNone');
	Ext.get('delayjsonloading').removeCls('dispBlck');
	Ext.get('pgxtabbarTab3').addCls('hidden');
	Ext.get('pgxtabbarTab3').removeCls('visible');
}

function showPGxSecondStep(){
	$(".currencyDrop").hide();
	toactivepgxspinner();
	managepgxapplication();
	managetab("pgxreviewquote", "stepone", 'pgxtabbar');	
	addPgxSNP();
	addPgxSNP_new();
	addPgxCNV();
	addPGxGenoTubeMadeToOrder();
	addPGxGenoTubeCustom();
	InputsDetails();
	showdetailQuote();
	var display = $('#display').val();
	IntrumentsTrainingTable(display);	
	//displayquotesummary();
	checklowvaluednareagent();
	UpdateQuoteSummary();
	//preparePGxQuoteSummaryHTML();
	
	Ext.get('delayjsonloading').addCls('dispNone');
	Ext.get('delayjsonloading').removeCls('dispBlck');
	
	var pgxintallationinstallneedobj = Ext.get("pgxintallation_installneed").dom;
	var pgxintallationinstallneedValue = pgxintallationinstallneedobj.options[pgxintallationinstallneedobj.selectedIndex].value;
	
	if(pgxintallationinstallneedValue == "IQ/OQ/IPV"){
		$("#showmoreimg").hide();
		$("#showlessimg").hide();	
		$('#display').val('less');
	} else {
		$("#showmoreimg").show();
		$("#showlessimg").hide();
		$('#display').val('more');
	}
}

function checklowvaluednareagent(){
	var dnaExtraction = getExperimentInfo("DNAExtraction");
	Ext.get(dnaExtraction).dom.checked = true;
	if($("#dnareagent").val() == 0){ 
		Ext.get('DNAExtraction-MagMAXReag_chkbx_0').dom.checked = true;	
		Ext.get('DNAExtraction-MagMAXReag_chkbx_1').dom.checked = false;		
		//Ext.get('DNAExtraction-MagMAXReag_chkbx_2').dom.checked = false;								
	} else if($("#dnareagent").val() == 1){ 
		Ext.get('DNAExtraction-MagMAXReag_chkbx_1').dom.checked = true;
		Ext.get('DNAExtraction-MagMAXReag_chkbx_0').dom.checked = false;
		//Ext.get('DNAExtraction-MagMAXReag_chkbx_2').dom.checked = false;																
	} else if($("#dnareagent").val() == 2){	
		//Ext.get('DNAExtraction-MagMAXReag_chkbx_2').dom.checked = true;
		Ext.get('DNAExtraction-MagMAXReag_chkbx_0').dom.checked = false;
		Ext.get('DNAExtraction-MagMAXReag_chkbx_1').dom.checked = false;															
	}
}

function showstepone() {
        managetab("stepone", activetabid, 'pgxtabbar');
		/*if($("#pgxbtn").hasClass('pgxtbuttonselected')){
			$("#viewTab").addCls('hidden').removeCls('visible');
		} else {
			$("#viewTab").addCls('visible').removeCls('hidden');
		}*/
       $(".currencyDrop").show();
	   Ext.get('viewTab').addCls('visible').removeCls('hidden');
    }
	
function managepgxapplication(){
	Ext.get('steptwo').removeCls('visible');
	Ext.get('steptwo').addCls('hidden');
	
	Ext.get('pgxreviewquote').removeCls('hidden');
	Ext.get('pgxreviewquote').addCls('visible');	
}

function calcforPGXInputs(){ 
	var pgxsamples = Ext.get('no_of_pgxsamples').dom.value;
	var pgxsamplecalctype = Ext.get("pgxsamplecombobox").dom;
	var pgxsnpsample = Ext.get('pgxsnpsample').dom.value;
    var selectpgxsampleObjValue = pgxsamplecalctype.options[pgxsamplecalctype.selectedIndex].value;
	var totaldwmy = 0;
	if(selectpgxsampleObjValue == "days"){
		totaldwmy = pgxsamples * 365;
	}else if(selectpgxsampleObjValue == "weeks"){
		totaldwmy = pgxsamples * 52;
	}else if(selectpgxsampleObjValue == "months"){
		totaldwmy = pgxsamples * 12;
	}else if(selectpgxsampleObjValue == "years"){
		totaldwmy = pgxsamples * 1;
	}
	
	Ext.get("hdpgxsampleval").dom.value = totaldwmy;
	$("#calcreagents").html(selectpgxsampleObjValue);
	//DNA Extraction calculation 
	Ext.get('max_sample_per_year').dom.value = (Ext.get('max_sample_per_day').dom.value * 365);
	Ext.get('use_of_pgxinstruments').dom.value = Math.round(((totaldwmy / Ext.get('max_sample_per_year').dom.value) *100), 5);
	Ext.get('recommended_pgxinstruments').dom.value =  Math.ceil(Ext.get('use_of_pgxinstruments').dom.value / 100);
	Ext.get('pgxdnavalues').dom.value = Ext.get('recommended_pgxinstruments').dom.value ;
	
	//SNP Calculation
	var pgxsnpopenarraycalctypeobj = Ext.get("pgxsnpopenarrayformat").dom;
	var selectpgxsnpopenarrayObjValue = pgxsnpopenarraycalctypeobj.options[pgxsnpopenarraycalctypeobj.selectedIndex].value;

	var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
	var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
	
	//alert(selectpgxsnpopenarrayObjValue);
	//alert(selectpgxsnpopenarrayInstValue);

	if(selectpgxsnpopenarrayObjValue === "QuantStudio 12K"){
		if(selectpgxsnpopenarrayInstValue === "OpenArray-26 assays"){
			Ext.get('max_snpsample_per_day').dom.value = 96 * 4 * 3;
			$("#pgxsnpsampletr").hide();
		}else if(selectpgxsnpopenarrayInstValue === "OpenArray-60 assays"){
			Ext.get('max_snpsample_per_day').dom.value = 48 * 4 * 3;
			$("#pgxsnpsampletr").hide();
		}else if(selectpgxsnpopenarrayInstValue === "OpenArray-120 assays"){
			Ext.get('max_snpsample_per_day').dom.value = 24 * 4 * 3;
			$("#pgxsnpsampletr").hide();
		}else if(selectpgxsnpopenarrayInstValue === "OpenArray-180 assays"){
			Ext.get('max_snpsample_per_day').dom.value = 16 * 4 * 3;
			$("#pgxsnpsampletr").hide();
		}else if(selectpgxsnpopenarrayInstValue === "OpenArray-240 assays"){
			Ext.get('max_snpsample_per_day').dom.value = 12 * 4 * 3;
			$("#pgxsnpsampletr").hide();
		}else if(selectpgxsnpopenarrayInstValue === "Low Density Array"){
			Ext.get('max_snpsample_per_day').dom.value = 1 * 4 * 3;
			$("#pgxsnpsampletr").hide();
		}else if(selectpgxsnpopenarrayInstValue === "96-well Standard"){
			Ext.get('max_snpsample_per_day').dom.value = Math.round((96/pgxsnpsample)*3);
			$("#pgxsnpsampletr").show();
		}else if(selectpgxsnpopenarrayInstValue === "96-well Fast"){
			Ext.get('max_snpsample_per_day').dom.value = (96/pgxsnpsample)*4;
			$("#pgxsnpsampletr").show();
		}else if(selectpgxsnpopenarrayInstValue === "384-well"){
			Ext.get('max_snpsample_per_day').dom.value = (384/pgxsnpsample)*4;
			$("#pgxsnpsampletr").show();
		}
	}else if(selectpgxsnpopenarrayObjValue === "QuantStudio 7"){
		if(selectpgxsnpopenarrayInstValue === "Low Density Array"){	
			Ext.get('max_snpsample_per_day').dom.value = 1 * 4 * 3;
		}else if(selectpgxsnpopenarrayInstValue === "96-well Standard"){
			Ext.get('max_snpsample_per_day').dom.value = (96/pgxsnpsample)*3;
			$("#pgxsnpsampletr").show();
		}else if(selectpgxsnpopenarrayInstValue === "96-well Fast"){
			Ext.get('max_snpsample_per_day').dom.value = (96/pgxsnpsample)*4;
			$("#pgxsnpsampletr").show();
		}else if(selectpgxsnpopenarrayInstValue === "384-well"){
			Ext.get('max_snpsample_per_day').dom.value = (384/pgxsnpsample)*4;
			$("#pgxsnpsampletr").show();
		}
	}else if(selectpgxsnpopenarrayObjValue === "QuantStudio 6"){	
		if(selectpgxsnpopenarrayInstValue === "96-well Standard"){ 
			Ext.get('max_snpsample_per_day').dom.value = (96/pgxsnpsample)*3;
			$("#pgxsnpsampletr").show();
		}else if(selectpgxsnpopenarrayInstValue === "96-well Fast"){
			Ext.get('max_snpsample_per_day').dom.value = (96/pgxsnpsample)*4;
			$("#pgxsnpsampletr").show();
		}else if(selectpgxsnpopenarrayInstValue === "384-well"){
			Ext.get('max_snpsample_per_day').dom.value = (384/pgxsnpsample)*4;
			$("#pgxsnpsampletr").show();
		}
	}else if(selectpgxsnpopenarrayObjValue === "ViiA7"){
		if(selectpgxsnpopenarrayInstValue === "Low Density Array"){
			Ext.get('max_snpsample_per_day').dom.value = 1 * 4 * 3;
		}else if(selectpgxsnpopenarrayInstValue === "96-well Standard"){
			Ext.get('max_snpsample_per_day').dom.value = 1 * 4 * 3;
		}else if(selectpgxsnpopenarrayInstValue === "96-well Fast"){
			Ext.get('max_snpsample_per_day').dom.value = 1 * 4 * 3;
		}else if(selectpgxsnpopenarrayInstValue === "384-well"){
			Ext.get('max_snpsample_per_day').dom.value = 1 * 4 * 3;
		}
	}
	Ext.get('pgxsnpformatneed').on('change', function (e) {
		addPgxSNP();
	});
	Ext.get('pgxcnainstrumentsneedtouse').on('change', function (e) {
		addPgxCNV();
	});		
	//alert(Ext.get('max_snpsample_per_day').dom.value);
	
	var totalsnpsamle = 0;
	if(selectpgxsampleObjValue == "days"){
		totalsnpsamle = pgxsamples * 365;
	}else if(selectpgxsampleObjValue == "weeks"){
		totalsnpsamle = pgxsamples * 52;
	}else if(selectpgxsampleObjValue == "months"){
		totalsnpsamle = pgxsamples * 12;
	}else if(selectpgxsampleObjValue == "years"){
		totalsnpsamle = pgxsamples * 1;
	}
	
	Ext.get('max_snpsample_per_year').dom.value = (Ext.get('max_snpsample_per_day').dom.value * 365);
	
	//Ext.get('use_of_snppgxinstruments').dom.value = Math.round((((totaldwmy / Ext.get('max_snpsample_per_day').dom.value) * Ext.get('pgxsnpreplicates').dom.value) * 100 ), 5);
	
	var useofsnpint = ((totalsnpsamle / Ext.get('max_snpsample_per_year').dom.value) * Ext.get('pgxsnpreplicates').dom.value)  * 100 ;
	Ext.get('use_of_snppgxinstruments').dom.value =  useofsnpint.toFixed(3);
	Ext.get('recommended_snppgxinstruments').dom.value =  Math.ceil(Ext.get('use_of_snppgxinstruments').dom.value / 100);
	Ext.get('pgxsnpqsoavalue').dom.value =  Math.ceil(Ext.get('use_of_snppgxinstruments').dom.value / 100);
	var pgxcnainstrumentsobj = Ext.get("pgxcnainstruments").dom;
	var pgxcnainstrumentsValue = pgxcnainstrumentsobj.options[pgxcnainstrumentsobj.selectedIndex].value;
	
	//CNV calculation
	var pgxcnvopenarraycalctypeobj = Ext.get("pgxcnainstruments").dom;
	var selectpgxcnvopenarrayObjValue = pgxcnvopenarraycalctypeobj.options[pgxcnvopenarraycalctypeobj.selectedIndex].value;

	var pgxcnvinstrucalctypeobj = Ext.get("pgxcnainstrumentsneedtouse").dom;
	var selectpgxcnvInstValue = pgxcnvinstrucalctypeobj.options[pgxcnvinstrucalctypeobj.selectedIndex].value;
	var cnvsamplevalue = Ext.get('pgxcnasample').dom.value;
	var cnvsampleperday_pgx = 0;
	var isPGXSNPCNVInstrumentSame = false;
	var isPGXSNPCNVBlockSame = false;
	
	if( selectpgxcnvopenarrayObjValue === "Same instrument as SNP analysis" || selectpgxcnvopenarrayObjValue == selectpgxsnpopenarrayObjValue ){
		selectpgxcnvopenarrayObjValue = selectpgxsnpopenarrayObjValue;
		isPGXSNPCNVInstrumentSame = true; 
	}

	if( selectpgxcnvInstValue === "Same block as SNP analysis" || selectpgxcnvInstValue == selectpgxsnpopenarrayInstValue){
		selectpgxcnvInstValue = selectpgxsnpopenarrayInstValue;
		isPGXSNPCNVBlockSame = true;
	}
	
	if(isValidIstrumrntsforPGX()){
		if(selectpgxcnvopenarrayObjValue === "QuantStudio 12K"){
			if(selectpgxcnvInstValue === "96-well Standard"){
				cnvsampleperday_pgx = (96/cnvsamplevalue)*3;				
			}else if(selectpgxcnvInstValue === "96-well Fast"){
				cnvsampleperday_pgx = (96/cnvsamplevalue)*4;				
			}else if(selectpgxcnvInstValue === "384-well"){
				cnvsampleperday_pgx = (384/cnvsamplevalue)*4;				
			}
		}else if(selectpgxcnvopenarrayObjValue === "QuantStudio 7"){
			if(selectpgxcnvInstValue === "96-well Standard"){
				cnvsampleperday_pgx = (96/cnvsamplevalue)*3;				
			}else if(selectpgxcnvInstValue === "96-well Fast"){
				cnvsampleperday_pgx = (96/cnvsamplevalue)*4;				
			}else if(selectpgxcnvInstValue === "384-well"){
				cnvsampleperday_pgx = (384/cnvsamplevalue)*4;				
			}
		
		}else if(selectpgxcnvopenarrayObjValue === "QuantStudio 6"){

			if(selectpgxcnvInstValue === "96-well Standard"){
				cnvsampleperday_pgx = (96/cnvsamplevalue)*3;				
			}else if(selectpgxcnvInstValue === "96-well Fast"){
				cnvsampleperday_pgx = (96/cnvsamplevalue)*4;				
			}else if(selectpgxcnvInstValue === "384-well"){
				cnvsampleperday_pgx = (384/cnvsamplevalue)*4;				
			}
		}else if(selectpgxcnvopenarrayObjValue === "ViiA7"){
			if(selectpgxcnvInstValue === "96-well Standard"){
				cnvsampleperday_pgx = (96/cnvsamplevalue)*3;				
			}else if(selectpgxcnvInstValue === "96-well Fast"){
				cnvsampleperday_pgx = (96/cnvsamplevalue)*4;				
			}else if(selectpgxcnvInstValue === "384-well"){
				cnvsampleperday_pgx = (384/cnvsamplevalue)*4;				
			}
		}
		Ext.get('max_cnasample_per_day').dom.value =  Math.round(cnvsampleperday_pgx);
		Ext.get('max_cnasample_per_year').dom.value =  Math.round((cnvsampleperday_pgx * 365));
		if(isPGXSNPCNVInstrumentSame && ! isPGXSNPCNVBlockSame){ 
			var noofBlock =  Math.ceil( Math.round(((totalsnpsamle / Ext.get('max_cnasample_per_day').dom.value) * 100 ), 3) / 100 );
			//Ext.get('use_of_cnvpgxinstruments').dom.value = Math.round((((totaldwmy / Ext.get('max_cnasample_per_day').dom.value) * Ext.get('pgxsnpreplicates').dom.value) * 100 ), 5);
			var useofcnvint = totalsnpsamle / Ext.get('max_cnasample_per_year').dom.value * 100;			
			Ext.get('use_of_cnvpgxinstruments').dom.value = useofcnvint.toFixed(3);
			Ext.get('recommended_cnvpgxinstruments').dom.value =  0;
			Ext.get('pgxcnanoofinstruments').dom.value =  Ext.get('pgxsnpqsoavalue').dom.value;
		} else if(!isPGXSNPCNVInstrumentSame && isPGXSNPCNVBlockSame){ 
			var noofBlock =  Math.ceil( Math.round(((totalsnpsamle / Ext.get('max_cnasample_per_year').dom.value) * 100 ), 3) / 100 );
			//Ext.get('use_of_cnvpgxinstruments').dom.value = Math.round((((totaldwmy / Ext.get('max_cnasample_per_day').dom.value) * Ext.get('pgxsnpreplicates').dom.value) * 100 ), 5);
			var useofcnvint = totalsnpsamle / Ext.get('max_cnasample_per_year').dom.value * 100;			
			Ext.get('use_of_cnvpgxinstruments').dom.value = useofcnvint.toFixed(3);
			Ext.get('recommended_cnvpgxinstruments').dom.value =  noofBlock;
			Ext.get('pgxcnanoofinstruments').dom.value =  noofBlock;
		}else if( isPGXSNPCNVInstrumentSame && isPGXSNPCNVBlockSame){ 
			Ext.get('use_of_cnvpgxinstruments').dom.value = Math.round((((totaldwmy / Ext.get('max_cnasample_per_year').dom.value) * Ext.get('pgxsnpreplicates').dom.value) * 100 ), 5);
			//Ext.get('use_of_cnvpgxinstruments').dom.value = 0;
			Ext.get('recommended_cnvpgxinstruments').dom.value =  0;
			Ext.get('pgxcnanoofinstruments').dom.value =  0;
		}else{ 
			//Ext.get('use_of_cnvpgxinstruments').dom.value = Math.round((((totalsnpsamle / Ext.get('max_cnasample_per_day').dom.value) * Ext.get('pgxsnpreplicates').dom.value) * 100 ), 5);
			var noofBlock =  Math.ceil( Math.round(((totalsnpsamle / Ext.get('max_cnasample_per_year').dom.value) * 100 ), 3) / 100 );
			var useofcnvint = totalsnpsamle / Ext.get('max_cnasample_per_year').dom.value * 100;			
			Ext.get('use_of_cnvpgxinstruments').dom.value = useofcnvint.toFixed(3);
			Ext.get('recommended_cnvpgxinstruments').dom.value =  noofBlock;
			Ext.get('pgxcnanoofinstruments').dom.value = noofBlock;
		}
		/*if(pgxcnainstrumentsValue.indexOf("Same") == 0 ){
			Ext.get('pgxcnanoofinstruments').dom.value = Ext.get('pgxsnpqsoavalue').dom.value;
		} else {
			Ext.get('pgxcnanoofinstruments').dom.value = Math.ceil(Ext.get('use_of_cnvpgxinstruments').dom.value / 100);
		}*/
	}else{
		Ext.get('max_cnasample_per_day').dom.value =  0;
		Ext.get('max_cnasample_per_year').dom.value = 0;
		Ext.get('use_of_cnvpgxinstruments').dom.value = 0;
		Ext.get('recommended_cnvpgxinstruments').dom.value =  0;	
	}
}


function calcforPGXCnvInputs(){
	var pgxsamples = Ext.get('no_of_pgxsamples').dom.value;
	var pgxsamplecalctype = Ext.get("pgxsamplecombobox").dom;
	var pgxsnpsample = Ext.get('pgxsnpsample').dom.value;
    var selectpgxsampleObjValue = pgxsamplecalctype.options[pgxsamplecalctype.selectedIndex].value;
	var totaldwmy = 0;
	if(selectpgxsampleObjValue == "days"){
		totaldwmy = pgxsamples * 1;
	}else if(selectpgxsampleObjValue == "weeks"){
		totaldwmy = pgxsamples * 52;
	}else if(selectpgxsampleObjValue == "months"){
		totaldwmy = pgxsamples * 12;
	}else if(selectpgxsampleObjValue == "years"){
		totaldwmy = pgxsamples * 365;
	}
	
	Ext.get("hdpgxsampleval").dom.value = totaldwmy;
	$("#calcreagents").html(selectpgxsampleObjValue);
	//DNA Extraction calculation 
	Ext.get('max_sample_per_year').dom.value = (Ext.get('max_sample_per_day').dom.value * 365);
	Ext.get('use_of_pgxinstruments').dom.value = Math.round(((totaldwmy / Ext.get('max_sample_per_day').dom.value) *100), 5);
	Ext.get('recommended_pgxinstruments').dom.value =  Math.ceil(Ext.get('use_of_pgxinstruments').dom.value / 100);
	Ext.get('pgxdnavalues').dom.value = Ext.get('recommended_pgxinstruments').dom.value ;
	
	var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
	var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
	
	//CNV calculation
	var pgxsnpopenarraycalctypeobj = Ext.get("pgxsnpopenarrayformat").dom;
	var selectpgxsnpopenarrayObjValue = pgxsnpopenarraycalctypeobj.options[pgxsnpopenarraycalctypeobj.selectedIndex].value;
	
	var pgxcnvopenarraycalctypeobj = Ext.get("pgxcnainstruments").dom;
	var selectpgxcnvopenarrayObjValue = pgxcnvopenarraycalctypeobj.options[pgxcnvopenarraycalctypeobj.selectedIndex].value;

	var pgxcnvinstrucalctypeobj = Ext.get("pgxcnainstrumentsneedtouse").dom;
	var selectpgxcnvInstValue = pgxcnvinstrucalctypeobj.options[pgxcnvinstrucalctypeobj.selectedIndex].value;
	var cnvsamplevalue = Ext.get('pgxcnasample').dom.value;
	var cnvsampleperday_pgx = 0;

	if( selectpgxcnvopenarrayObjValue === "Same instrument as SNP analysis" ){
		selectpgxcnvopenarrayObjValue = selectpgxsnpopenarrayObjValue;
	}

	if( selectpgxcnvInstValue === "Same block as SNP analysis" ){
		selectpgxcnvInstValue = selectpgxsnpopenarrayInstValue;
	}
	
	if(isValidIstrumrntsforPGX()){
		if(selectpgxcnvopenarrayObjValue === "QuantStudio 12K"){
			if(selectpgxcnvInstValue === "96-well Standard"){
				cnvsampleperday_pgx = (96/cnvsamplevalue)*3;				
			}else if(selectpgxcnvInstValue === "96-well Fast"){
				cnvsampleperday_pgx = (96/cnvsamplevalue)*4;				
			}else if(selectpgxcnvInstValue === "384-well"){
				cnvsampleperday_pgx = (384/cnvsamplevalue)*4;				
			}
		}else if(selectpgxcnvopenarrayObjValue === "QuantStudio 7"){
			if(selectpgxcnvInstValue === "96-well Standard"){
				cnvsampleperday_pgx = (96/cnvsamplevalue)*3;				
			}else if(selectpgxcnvInstValue === "96-well Fast"){
				cnvsampleperday_pgx = (96/cnvsamplevalue)*4;				
			}else if(selectpgxcnvInstValue === "384-well"){
				cnvsampleperday_pgx = (384/cnvsamplevalue)*4;				
			}
		
		}else if(selectpgxcnvopenarrayObjValue === "QuantStudio 6"){

			if(selectpgxcnvInstValue === "96-well Standard"){
				cnvsampleperday_pgx = (96/cnvsamplevalue)*3;				
			}else if(selectpgxcnvInstValue === "96-well Fast"){
				cnvsampleperday_pgx = (96/cnvsamplevalue)*4;				
			}else if(selectpgxcnvInstValue === "384-well"){
				cnvsampleperday_pgx = (384/cnvsamplevalue)*4;				
			}
		}else if(selectpgxcnvopenarrayObjValue === "ViiA7"){
			if(selectpgxcnvInstValue === "96-well Standard"){
				cnvsampleperday_pgx = (96/cnvsamplevalue)*3;				
			}else if(selectpgxcnvInstValue === "96-well Fast"){
				cnvsampleperday_pgx = (96/cnvsamplevalue)*4;				
			}else if(selectpgxcnvInstValue === "384-well"){
				cnvsampleperday_pgx = (384/cnvsamplevalue)*4;				
			}
		}
		Ext.get('max_cnasample_per_day').dom.value =  Math.round(cnvsampleperday_pgx);
		Ext.get('max_cnasample_per_year').dom.value =  Math.round((cnvsampleperday_pgx * 365));
		Ext.get('use_of_cnvpgxinstruments').dom.value = Math.round(((totaldwmy / Ext.get('max_cnasample_per_day').dom.value) * 100 ), 3);
		//Ext.get('use_of_cnapgx_96Fastins').dom.value = roundNumber(((totaldwmy / Ext.get('max_cnasample_per_year').dom.value) * 100 ), 3);
		//Ext.get('use_of_cnapgx_96Stdins').dom.value = roundNumber(((totaldwmy / Ext.get('max_cnasample_per_year').dom.value) * 100 ), 3);
		Ext.get('recommended_cnvpgxinstruments').dom.value =  Math.ceil(Ext.get('use_of_cnvpgxinstruments').dom.value / 100);
		//Ext.get('recommended_cnapgx_96Fastins').dom.value =  Math.ceil(Ext.get('use_of_cnapgx_96Fastins').dom.value / 100);
		//Ext.get('recommended_cnapgx_96Stdins').dom.value =  Math.ceil(Ext.get('use_of_cnapgx_96Stdins').dom.value / 100);
	}else{
		Ext.get('max_cnasample_per_day').dom.value =  0;
		Ext.get('max_cnasample_per_year').dom.value = 0;
		Ext.get('use_of_cnvpgxinstruments').dom.value = 0;
		//Ext.get('use_of_cnapgx_96Fastins').dom.value = 0;
		//Ext.get('use_of_cnapgx_96Stdins').dom.value = 0;
		Ext.get('recommended_cnvpgxinstruments').dom.value =  0;
		//Ext.get('recommended_cnapgx_96Fastins').dom.value =  0;
		//Ext.get('recommended_cnapgx_96Stdins').dom.value = 0;
	
	}
}

function InputsDetails(){
	var pgxsnpopenarraycalctypeobj = Ext.get("pgxsnpopenarrayformat").dom;
	var selectpgxsnpopenarrayObjValue = pgxsnpopenarraycalctypeobj.options[pgxsnpopenarraycalctypeobj.selectedIndex].value;
	
	var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
	var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
	
	
	var pgxcnvopenarraycalctypeobj = Ext.get("pgxcnainstruments").dom;
	var selectpgxcnvopenarrayObjValue = pgxcnvopenarraycalctypeobj.options[pgxcnvopenarraycalctypeobj.selectedIndex].value;

	var pgxcnvinstrucalctypeobj = Ext.get("pgxcnainstrumentsneedtouse").dom;
	var selectpgxcnvInstValue = pgxcnvinstrucalctypeobj.options[pgxcnvinstrucalctypeobj.selectedIndex].value;
	
	var pgxintallation_comsysvalid = $('input[name=pgxintallation_comsysvalid]:radio:checked').val();
	
	
	var pgxintallation_installneedobj = Ext.get("pgxintallation_installneed").dom;
	var selectpgxinstallneedObjValue = pgxintallation_installneedobj.options[pgxintallation_installneedobj.selectedIndex].value;
	
	
	var pgxintallation_addtrainingobj = Ext.get("pgxintallation_addtraining").dom;
	var selectpgxintallation_addtrainingObjValue = pgxintallation_addtrainingobj.options[pgxintallation_addtrainingobj.selectedIndex].value;
	
	var table ='';	
	table = table+ '<TABLE id = "pgsInputdeatils" class = "verticalLine" style="border-right: 1px solid #5F5F5F;">';
	table = table+ 		'<TR>';
	table = table+ 			'<TD width="25%"></TD>';
	table = table+ 			'<TD width="40%" ></TD>';
	table = table+ 			'<TD width="34%"></TD>';
	table = table+ 			'</TR>';
	table = table+ 		'<TR class = "pgxtablerowheight" style="height: 40px">';
	table = table+			'<TD class="lablemedium SubHeading" width="25%">DNA Extraction</TD>';
	table = table+			'<TD width="40%" class="lablemedium SubHeading">MagMax system</TD>';
	if(getExperimentInfo("generateQuoteFor") == "Instruments and reagents"){
		table = table+			'<TD width="34%" class="lablemedium SubHeading">'+$('#pgxdnavalues').val()+'</TD>';
	}
	table = table+		'</TR>';
	table = table+		'<TR class = "pgxtablerowheight" style="height: 40px">';
	table = table+			'<TD class="lablemedium SubHeading">SNP Analysis</TD>';
	table = table+			'<TD class="lablemedium SubHeading">'+selectpgxsnpopenarrayObjValue+' - '+selectpgxsnpopenarrayInstValue+'</TD>';
	if(getExperimentInfo("generateQuoteFor") == "Instruments and reagents"){
		table = table+			'<TD class="lablemedium SubHeading">'+$('#pgxsnpqsoavalue').val()+'</TD>';
	}
	table = table+		'</TR>';
	table = table+		'<TR class = "pgxtablerowheight" style="height: 40px">';
	table = table+			'<TD class="lablemedium SubHeading">CNV Analysis</TD>';
	table = table+			'<TD class="lablemedium SubHeading">'+selectpgxcnvopenarrayObjValue+' - '+selectpgxcnvInstValue+'</TD>';
	if(getExperimentInfo("generateQuoteFor") == "Instruments and reagents"){
		table = table+			'<TD class="lablemedium SubHeading">'+$('#pgxcnanoofinstruments').val()+'</TD>';
	}
	table = table+		'</TR>';
	if(getExperimentInfo("generateQuoteFor") == "Instruments and reagents"){
		table = table+		'<TR class = "pgxtablerowheight" style="height: 40px">';
		table = table+			'<TD class="lablemedium SubHeading" rowspan="4">Support and Training</TD>';
		table = table+			'<TD class="lablemedium SubHeading">Validation package</TD>';
		table = table+			'<TD class="lablemedium SubHeading">'+pgxintallation_comsysvalid+'</TD>';
		table = table+		'</TR>';
		table = table+		'<TR class="lablemedium SubHeading" style="height: 40px">';
		table = table+			'<TD class="lablemedium SubHeading">Instrument installation</TD>';
		table = table+			'<TD class="lablemedium SubHeading">'+selectpgxinstallneedObjValue+'</TD>';
		table = table+		'</TR>';
		table = table+		'<TR class="lablemedium SubHeading" style="height: 40px">';
		table = table+			'<TD class="lablemedium SubHeading">Additional training</TD>';
		table = table+			'<TD class="lablemedium SubHeading">'+selectpgxintallation_addtrainingObjValue+'</TD>';
		table = table+		'</TR>';
		table = table+		'<TR class="lablemedium SubHeading" style="height: 40px">';
		table = table+			'<TD class="lablemedium SubHeading">Type of guarantee</TD>';
		table = table+			'<TD>Complete service (24 hours)</TD>';
		table = table+		'</TR>';
	}
	table = table+		'<TR class="lablemedium SubHeading" style="height: 40px">';
	table = table+			'<TD colspan="3">';
	table = table+				'<div class="ModifySearch">';
	table = table+					'<span id="pgxchangesearch" onclick="showstepone();" class="lablemedium left" style="color:#fff;">Modify Inputs</span>';
	table = table+				'</div>';
	table = table+			'</TD>';
	table = table+		'</TR>';
	table = table+	'</TABLE>';
	if(getExperimentInfo("generateQuoteFor") == "Reagents only"){
		table = table+	'<div id="" style="height:170px;width:1px;border-right: 1px solid #5F5F5F;margin-top: -165px;float:right;"></div>';
	}
	$("#InputsDiv").html(table);
}

function createpgxDNAtable(blockId, recobj, rowtitle){
	
	var no_of_pgxsamples = getExperimentInfo('no_of_pgxsamples');
	var noofreactions =  noofreplicates	* Number(no_of_pgxsamples);
	var html ='';
	html = html +'<TABLE border="0" id="'+blockId+'_Table" style="font-size: 13px;">';
	if(getExperimentInfo("generateQuoteFor") == "Instruments and reagents"){
		html = html +	'<TR>';
		html = html +		'<TH width="4%"> </TH>';
		html = html +		'<TH width="26%">Instrument</TH>';
		html = html +		'<TH width="10%">P/N</TH>';
		//html = html +		'<TH width="10%">Description</TH>';
		html = html +		'<TH width="10%">Qty</TH>';
		html = html +		'<TH width="10%">Unit List Price</TH>';
		html = html +		'<TH width="10%">% discount</TH>';
		html = html +		'<TH width="10%">Unit Sell Price</TH>';
		html = html +		'<TH width="10%">Total Sell Price</TH>';
		html = html +	'</TR>';
	}
	
	if(blockId == "DNAExtraction" ){
		var MagMaxinstruobj = recobj.raw.magmaxinstrument;
		var instruhtml = PgxDnaExtractionProcess(blockId, MagMaxinstruobj, 'MagMAXInstru');
		if(getExperimentInfo("generateQuoteFor") == "Instruments and reagents"){
			html = html + instruhtml;
		}
	}else if(blockId == "SNP"){
		var snpinsthtml = PgxSnpInstruments( blockId, 'MagMAXInstru');
		if(getExperimentInfo("generateQuoteFor") == "Instruments and reagents"){
			html = html + snpinsthtml;
		}
	}else if(blockId == "CNV"){	
		var cnvinsthtml = PgxCnvInstruments( blockId, 'MagMAXInstru');
		if(getExperimentInfo("generateQuoteFor") == "Instruments and reagents"){
			html = html + cnvinsthtml;
		}
	}
	
	html = html +	'<TR>';
	html = html +		'<TH width="4%"> </TH>';
	html = html +		'<TH width="26%">'+rowtitle+' Consumables</TH>';
	html = html +		'<TH width="10%"></TH>';
	//html = html +		'<TH width="10%">Description</TH>';
	html = html +		'<TH width="10%"></TH>';
	html = html +		'<TH width="10%"></TH>';
	html = html +		'<TH width="10%"></TH>';
	html = html +		'<TH width="10%"></TH>';
	html = html +		'<TH width="10%"></TH>';
	html = html +	'</TR>';
	
	if(blockId == "DNAExtraction" ){
		var MagMaxConsumobj = recobj.raw.magmaxconsumables;
		var conshtml = PgxDnaExtractionProcess(blockId, MagMaxConsumobj, 'MagMAXCons')
		html = html + conshtml;
	}else if(blockId == "SNP"){
		var noofreplicates = Ext.get('pgxsnpreplicates').dom.value;
		var noofsnptargets = Ext.get('pgxsnpsample').dom.value;
		noofreactions =  noofreplicates	* Number(no_of_pgxsamples) * noofsnptargets;
		//var rec = outputList.findRecord('pno', 100, 0, false, false, true);
		var rec = outputList.findRecord('pno', 102, 0, false, false, true);		
		var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
		var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
		
		if(selectpgxsnpopenarrayInstValue === '384-well'){
			var refofconsunits = Math.ceil(noofreactions / 384);
			var nooffilmunits = Math.ceil(refofconsunits / 100);
			var noofconsunits = Math.ceil(refofconsunits / 500);
			console.log("noofreactions - "+noofreactions+ "/" +384);
			console.log("refofconsunits - "+refofconsunits+ "/" +100);
			html = html +	'<TR >';		
			html = html +		'<TD id="'+blockId+'-MagMAXCons_chk_1"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" id="'+blockId+'-MagMAXCons_chkbx_1" checked="checked"> </TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_instrument_1">MicroAmp® Optical 384-Well Reaction Plate</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_partno_1" >4343370</TD>';
			var assayCostPerUnit = pricelist.findRecord('partnumber', 4343370).regions().findRecord('region', region + "-" + currency).get('price');
			//html = html +		'<TD id="'+blockId+'-MagMAXCons_desc_1"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_quantity_1"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-MagMAXCons_qty_1" name="" value = "'+noofconsunits+'"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitprice_1">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_disc_1"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-MagMAXCons_discper_1"  name=""></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitsellprice_1">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			
			var temptot = noofconsunits * assayCostPerUnit;
			SNPconsumtotal = SNPconsumtotal + temptot;
			
			html = html +		'<TD id="'+blockId+'-MagMAXCons_totalprice_1">'+convertCurrency(temptot, region + "-" + currency)+'</TD>';
			html = html +	'</TR>';
			html = html +	'<TR>';
			
			html = html +	'<TR >';		
			html = html +		'<TD id="'+blockId+'-MagMAXCons_chk_2"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" id="'+blockId+'-MagMAXCons_chkbx_2" checked="checked"> </TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_instrument_2">MicroAmp® Optical Adhesive Film</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_partno_2" >4311971</TD>';
			var assayCostPerUnit = pricelist.findRecord('partnumber', 4311971).regions().findRecord('region', region + "-" + currency).get('price');
			//html = html +		'<TD id="'+blockId+'-MagMAXCons_desc_2"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_quantity_2"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-MagMAXCons_qty_2" name="" value = "'+nooffilmunits+'"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitprice_2">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_disc_2"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-MagMAXCons_discper_2"  name=""></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitsellprice_2">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			
			var temptot = nooffilmunits * assayCostPerUnit;
			SNPconsumtotal = SNPconsumtotal + temptot;	
			
			html = html +		'<TD id="'+blockId+'-MagMAXCons_totalprice_2">'+convertCurrency(temptot, region + "-" + currency)+'</TD>';
			html = html +	'</TR>';
			html = html +	'<TR>';
		} else if (selectpgxsnpopenarrayInstValue === '96-well Fast'){
			var refofconsunits = Math.ceil(noofreactions / 96);
			var nooffilmunits = Math.ceil(refofconsunits / 100);
			var noofconsunits = Math.ceil(refofconsunits / 500);
			html = html +	'<TR >';		
			html = html +		'<TD id="'+blockId+'-MagMAXCons_chk_1"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" id="'+blockId+'-MagMAXCons_chkbx_1" checked="checked"> </TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_instrument_1">MicroAmp® Fast Optical 96-Well Reaction Plate with Barcode, 0.1 mL</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_partno_1" >4366932</TD>';
			var assayCostPerUnit = pricelist.findRecord('partnumber', 4366932).regions().findRecord('region', region + "-" + currency).get('price');
			//html = html +		'<TD id="'+blockId+'-MagMAXCons_desc_1">200 Plates</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_quantity_1"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-MagMAXCons_qty_1" name="" value = "'+noofconsunits+'"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitprice_1">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_disc_1"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-MagMAXCons_discper_1"  name=""></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitsellprice_1">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			
			var temptot = noofconsunits * assayCostPerUnit;
			SNPconsumtotal = SNPconsumtotal + temptot;			
			
			html = html +		'<TD id="'+blockId+'-MagMAXCons_totalprice_1">'+convertCurrency(temptot, region + "-" + currency)+'</TD>';
			html = html +	'</TR>';
			html = html +	'<TR>';
			
			html = html +	'<TR >';		
			html = html +		'<TD id="'+blockId+'-MagMAXCons_chk_2"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" id="'+blockId+'-MagMAXCons_chkbx_2" checked="checked"> </TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_instrument_2">MicroAmp® Optical Adhesive Film</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_partno_2" >4311971</TD>';
			var assayCostPerUnit = pricelist.findRecord('partnumber', 4311971).regions().findRecord('region', region + "-" + currency).get('price');
			//html = html +		'<TD id="'+blockId+'-MagMAXCons_desc_2"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_quantity_2"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-MagMAXCons_qty_2" name="" value = "'+nooffilmunits+'"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitprice_2">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_disc_2"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-MagMAXCons_discper_2"  name=""></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitsellprice_2">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			
			var temptot = nooffilmunits * assayCostPerUnit;
			SNPconsumtotal = SNPconsumtotal + temptot;	CNVconsumtotal
			
			html = html +		'<TD id="'+blockId+'-MagMAXCons_totalprice_2">'+convertCurrency(temptot, region + "-" + currency)+'</TD>';
			html = html +	'</TR>';
			html = html +	'<TR>';
		} else if (selectpgxsnpopenarrayInstValue === '96-well Standard'){
			var refofconsunits = Math.ceil(noofreactions / 96);
			var nooffilmunits = Math.ceil(refofconsunits / 100);
			var noofconsunits = Math.ceil(refofconsunits / 500);
			html = html +	'<TR >';		
			html = html +		'<TD id="'+blockId+'-MagMAXCons_chk_1"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" id="'+blockId+'-MagMAXCons_chkbx_1" checked="checked"> </TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_instrument_1">MicroAmp® Optical 96-Well Reaction Plate, 500 Plates</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_partno_1" >4316813</TD>';
			var assayCostPerUnit = pricelist.findRecord('partnumber', 4316813).regions().findRecord('region', region + "-" + currency).get('price');
			//html = html +		'<TD id="'+blockId+'-MagMAXCons_desc_1">500 Plates</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_quantity_1"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-MagMAXCons_qty_1" name="" value = "'+noofconsunits+'"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitprice_1">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_disc_1"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-MagMAXCons_discper_1"  name=""></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitsellprice_1">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			
			var temptot = noofconsunits * assayCostPerUnit;
			SNPconsumtotal = SNPconsumtotal + temptot;			
			
			html = html +		'<TD id="'+blockId+'-MagMAXCons_totalprice_1">'+convertCurrency(temptot, region + "-" + currency)+'</TD>';
			html = html +	'</TR>';
			html = html +	'<TR>';
			
			html = html +	'<TR >';		
			html = html +		'<TD id="'+blockId+'-MagMAXCons_instrument_2"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" id="'+blockId+'-MagMAXCons_chkbx_2" checked="checked"> </TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_instrument_2">MicroAmp® Optical Adhesive Film</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_partno_2" >4311971</TD>';
			var assayCostPerUnit = pricelist.findRecord('partnumber', 4311971).regions().findRecord('region', region + "-" + currency).get('price');
			//html = html +		'<TD id="'+blockId+'-MagMAXCons_desc_2"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_quantity_2"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-MagMAXCons_qty_2" name="" value = "'+nooffilmunits+'"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitprice_2">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_disc_2"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-MagMAXCons_discper_2"  name=""></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitsellprice_2">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			
			var temptot = nooffilmunits * assayCostPerUnit;
			SNPconsumtotal = SNPconsumtotal + temptot;	
			
			html = html +		'<TD id="'+blockId+'-MagMAXCons_totalprice_2">'+convertCurrency(temptot, region + "-" + currency)+'</TD>';
			html = html +	'</TR>';
			html = html +	'<TR>';
		} else if (selectpgxsnpopenarrayInstValue === 'OpenArray-26 assays' || selectpgxsnpopenarrayInstValue === 'OpenArray-60 assays' || selectpgxsnpopenarrayInstValue === 'OpenArray-120 assays' || selectpgxsnpopenarrayInstValue === 'OpenArray-180 assays' || selectpgxsnpopenarrayInstValue === 'OpenArray-240 assays'){
			var openTargetArray = selectpgxsnpopenarrayInstValue.split("-")[1];
			var targetArray = openTargetArray.split(" ")[0];
			var pgxsnpsample = Ext.get('no_of_pgxsamples').dom.value;
			var pgxsamplecalctype = Ext.get("pgxsamplecombobox").dom;
			var selectpgxsampleObjValue = pgxsamplecalctype.options[pgxsamplecalctype.selectedIndex].value;
			var no_of_reagentsmonths = Ext.get("no_of_reagentsmonths").dom.value;
			pgxsnpsample = pgxsnpsample * no_of_reagentsmonths;
			
			var pgxnoofreplicate = Ext.get('pgxsnpreplicates').dom.value;
			updateExperimentInfo('openarrayinstrument',"QuantStudio");
			updateExperimentInfo('nooftargets', Number(targetArray));
			updateExperimentInfo('noofsamples', pgxsnpsample);
			updateExperimentInfo('noofreplicates', pgxnoofreplicate);
			updateExperimentInfo('noofsubarrays', pgxnoofreplicate);
			addOGTAPC();
			var rec = outputList.findRecord('pno', 7, 0, false, false, true);
			var openarray384wellsampleplatesunits = (rec.get('openarray384wellsampleplatesunits'));
			var accufillsystemtipsunits = (rec.get('openarrayaccufillsystemtipsunits')); 
			//var accufillsystemtipsunits = (rec.get('openarrayaccufillsystemtips10packunits')); 
			html = html +	'<TR >';		
			html = html +		'<TD id="'+blockId+'-MagMAXCons_chk_1"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" id="'+blockId+'-MagMAXCons_chkbx_1" checked="checked"> </TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_instrument_1">OpenArray® 384-well Sample Plates</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_partno_1" >4406947</TD>';
			var assayCostPerUnit = pricelist.findRecord('partnumber', 4406947).regions().findRecord('region', region + "-" + currency).get('price');
			
			//html = html +		'<TD id="'+blockId+'-MagMAXCons_desc_1"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_quantity_1"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-MagMAXCons_qty_1" name="" value = "'+openarray384wellsampleplatesunits+'"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitprice_1">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_disc_1"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-MagMAXCons_discper_1"  name=""></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitsellprice_1">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			
			var temptot = openarray384wellsampleplatesunits * assayCostPerUnit;
			SNPconsumtotal = SNPconsumtotal + temptot;			
			
			html = html +		'<TD id="'+blockId+'-MagMAXCons_totalprice_1">'+convertCurrency(temptot, region + "-" + currency)+'</TD>';
			html = html +	'</TR>';
			html = html +	'<TR>';
			
			html = html +	'<TR >';		
			html = html +		'<TD id="'+blockId+'-MagMAXCons_chk_2"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" id="'+blockId+'-MagMAXCons_chkbx_2" checked="checked"> </TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_instrument_2">OpenArray® AccuFill System Tips</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_partno_2" >4457246</TD>';
			var assayCostPerUnit = pricelist.findRecord('partnumber', 4457246).regions().findRecord('region', region + "-" + currency).get('price');
			//html = html +		'<TD id="'+blockId+'-MagMAXCons_desc_2"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_quantity_2"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-MagMAXCons_qty_2" name="" value = "'+accufillsystemtipsunits+'"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitprice_2">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_disc_2"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-MagMAXCons_discper_2"  name=""></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitsellprice_2">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			
			var temptot = accufillsystemtipsunits * assayCostPerUnit;
			SNPconsumtotal = SNPconsumtotal + temptot;			
			
			html = html +		'<TD id="'+blockId+'-MagMAXCons_totalprice_2">'+convertCurrency(temptot, region + "-" + currency)+'</TD>';
			html = html +	'</TR>';
			html = html +	'<TR>';
		}
			
	}else if(blockId == "CNV"){
		var rec = outputList.findRecord('pno', 101, 0, false, false, true);		
		var noofreplicates = 1;
		var noofcnvtargets = Ext.get('pgxcnasample').dom.value;
		noofreactions =  noofreplicates	* Number(no_of_pgxsamples) * noofcnvtargets;
		
		var pgxcnvinstrucalctypeobj = Ext.get("pgxcnainstrumentsneedtouse").dom; 
		var selectpgxcnvInstValue = pgxcnvinstrucalctypeobj.options[pgxcnvinstrucalctypeobj.selectedIndex].value;
		
		if(selectpgxcnvInstValue === "Same block as SNP analysis" ){
			var pgxsnpformatneedobj = Ext.get("pgxsnpformatneed").dom;
			selectpgxcnvFormatValue = pgxsnpformatneedobj.options[pgxsnpformatneedobj.selectedIndex].value;
		}else{
			selectpgxcnvFormatValue = selectpgxcnvInstValue;
		}
		/*
		var pgxcnasample = Ext.get('pgxcnasample').dom.value;
		var no_of_pgxsamples = Ext.get('no_of_pgxsamples').dom.value;
		var rxns = pgxcnasample *  no_of_pgxsamples;
		*/
		if(selectpgxcnvFormatValue === '384-well'){		
			/*
			var noofplates = Math.round(rxns/384);
			var noofcnvunits = Math.ceil(noofplates / 1000);			
			*/
			
			
			var refofconsunits = Math.ceil(noofreactions / 384);
			var nooffilmunits = Math.ceil(refofconsunits / 100);
			var noofcnvunits = Math.ceil(refofconsunits / 500);
			
			
			html = html +	'<TR >';		
			html = html +		'<TD id="'+blockId+'-MagMAXCons_chk_1"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" id="'+blockId+'-MagMAXCons_chkbx_1" checked="checked"> </TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_instrument_1">MicroAmp® Optical 384-Well Reaction Plate</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_partno_1" >4343370</TD>';
			var assayCostPerUnit = pricelist.findRecord('partnumber', 4343370).regions().findRecord('region', region + "-" + currency).get('price');
			//html = html +		'<TD id="'+blockId+'-MagMAXCons_desc_1"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_quantity_1"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-MagMAXCons_qty_1" name="" value = "'+noofcnvunits+'"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitprice_1">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_disc_1"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-MagMAXCons_discper_1"  name=""></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitsellprice_1">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			
			var temptot = noofcnvunits * assayCostPerUnit;
			CNVconsumtotal = CNVconsumtotal + temptot;	
			
			html = html +		'<TD id="'+blockId+'-MagMAXCons_totalprice_1">'+convertCurrency(temptot, region + "-" + currency)+'</TD>';
			html = html +	'</TR>';
			html = html +	'<TR>';
			
			html = html +	'<TR >';		
			html = html +		'<TD id="'+blockId+'-MagMAXCons_chk_2"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" id="'+blockId+'-MagMAXCons_chkbx_2" checked="checked"> </TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_instrument_2">MicroAmp® Optical Adhesive Film</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_partno_2" >4311971</TD>';
			var assayCostPerUnit = pricelist.findRecord('partnumber', 4311971).regions().findRecord('region', region + "-" + currency).get('price');
			//html = html +		'<TD id="'+blockId+'-MagMAXCons_desc_2"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_quantity_2"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-MagMAXCons_qty_2" name="" value = "'+nooffilmunits+'"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitprice_2">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_disc_2"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-MagMAXCons_discper_2"  name=""></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitsellprice_2">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			
			var temptot = nooffilmunits * assayCostPerUnit;
			SNPconsumtotal = SNPconsumtotal + temptot;	CNVconsumtotal
			
			html = html +		'<TD id="'+blockId+'-MagMAXCons_totalprice_2">'+convertCurrency(temptot, region + "-" + currency)+'</TD>';
			html = html +	'</TR>';
			html = html +	'<TR>';
		} else if (selectpgxcnvFormatValue === '96-well Fast'){
			/*
			var noofplates = Math.round(rxns/96);
			var noofcnvunits = Math.ceil(noofplates / 1000);
			*/
			var refofconsunits = Math.ceil(noofreactions / 96);
			var nooffilmunits = Math.ceil(refofconsunits / 100);
			var noofcnvunits = Math.ceil(refofconsunits / 500);
			html = html +	'<TR >';		
			html = html +		'<TD id="'+blockId+'-MagMAXCons_chk_1"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" id="'+blockId+'-MagMAXCons_chkbx_1" checked="checked"> </TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_instrument_1">MicroAmp® Fast Optical 96-Well Reaction Plate with Barcode, 0.1 mL</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_partno_1" >4366932</TD>';
			var assayCostPerUnit = pricelist.findRecord('partnumber', 4366932).regions().findRecord('region', region + "-" + currency).get('price');
			//html = html +		'<TD id="'+blockId+'-MagMAXCons_desc_1">200 Plates</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_quantity_1"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-MagMAXCons_qty_1" name="" value = "'+noofcnvunits+'"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitprice_1">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_disc_1"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-MagMAXCons_discper_1"  name=""></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitsellprice_1">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			
			var temptot = noofcnvunits * assayCostPerUnit;
			CNVconsumtotal = CNVconsumtotal + temptot;
			
			html = html +		'<TD id="'+blockId+'-MagMAXCons_totalprice_1">'+convertCurrency(temptot, region + "-" + currency)+'</TD>';
			html = html +	'</TR>';
			html = html +	'<TR>';
			
			html = html +	'<TR >';		
			html = html +		'<TD id="'+blockId+'-MagMAXCons_chk_2"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" id="'+blockId+'-MagMAXCons_chkbx_2" checked="checked"> </TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_instrument_2">MicroAmp® Optical Adhesive Film</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_partno_2" >4311971</TD>';
			var assayCostPerUnit = pricelist.findRecord('partnumber', 4311971).regions().findRecord('region', region + "-" + currency).get('price');
			//html = html +		'<TD id="'+blockId+'-MagMAXCons_desc_2"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_quantity_2"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-MagMAXCons_qty_2" name="" value = "'+nooffilmunits+'"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitprice_2">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_disc_2"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-MagMAXCons_discper_2"  name=""></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitsellprice_2">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			
			var temptot = nooffilmunits * assayCostPerUnit;
			SNPconsumtotal = SNPconsumtotal + temptot;	CNVconsumtotal
			
			html = html +		'<TD id="'+blockId+'-MagMAXCons_totalprice_2">'+convertCurrency(temptot, region + "-" + currency)+'</TD>';
			html = html +	'</TR>';
			html = html +	'<TR>';
		} else if (selectpgxcnvFormatValue === '96-well Standard'){
			/*
			var noofplates = Math.round(rxns/96);
			var noofcnvunits = Math.ceil(noofplates / 1000);
			*/
			var refofconsunits = Math.ceil(noofreactions / 96);
			var nooffilmunits = Math.ceil(refofconsunits / 100);
			var noofcnvunits = Math.ceil(refofconsunits / 500);
			html = html +	'<TR >';		
			html = html +		'<TD id="'+blockId+'-MagMAXCons_chk_1"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" id="'+blockId+'-MagMAXCons_chkbx_1" checked="checked"> </TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_instrument_1">MicroAmp® Optical 96-Well Reaction Plate</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_partno_1" >4316813</TD>';
			var assayCostPerUnit = pricelist.findRecord('partnumber', 4316813).regions().findRecord('region', region + "-" + currency).get('price');
			//html = html +		'<TD id="'+blockId+'-MagMAXCons_desc_1">500 Plates</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_quantity_1"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-MagMAXCons_qty_1" name="" value = "'+noofcnvunits+'"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitprice_1">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_disc_1"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-MagMAXCons_discper_1"  name=""></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitsellprice_1">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			
			var temptot = noofcnvunits * assayCostPerUnit;
			CNVconsumtotal = CNVconsumtotal + temptot;
			
			html = html +		'<TD id="'+blockId+'-MagMAXCons_totalprice_1">'+convertCurrency(temptot, region + "-" + currency)+'</TD>';
			html = html +	'</TR>';
			html = html +	'<TR>';
			
			html = html +	'<TR >';		
			html = html +		'<TD id="'+blockId+'-MagMAXCons_chk_2"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" id="'+blockId+'-MagMAXCons_chkbx_2" checked="checked"> </TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_instrument_2">MicroAmp® Optical Adhesive Film</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_partno_2" >4311971</TD>';
			var assayCostPerUnit = pricelist.findRecord('partnumber', 4311971).regions().findRecord('region', region + "-" + currency).get('price');
			//html = html +		'<TD id="'+blockId+'-MagMAXCons_desc_2"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_quantity_2"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-MagMAXCons_qty_2" name="" value = "'+nooffilmunits+'"></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitprice_2">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_disc_2"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-MagMAXCons_discper_2"  name=""></TD>';
			html = html +		'<TD id="'+blockId+'-MagMAXCons_unitsellprice_2">'+convertCurrency(assayCostPerUnit, region + "-" + currency)+'</TD>';
			
			var temptot = nooffilmunits * assayCostPerUnit;
			SNPconsumtotal = SNPconsumtotal + temptot;	CNVconsumtotal
			
			html = html +		'<TD id="'+blockId+'-MagMAXCons_totalprice_2">'+convertCurrency(temptot, region + "-" + currency)+'</TD>';
			html = html +	'</TR>';
			html = html +	'<TR>';
		}			
	}
	
	html = html +	'<TR>';
	html = html +		'<TH width="4%"> </TH>';
	html = html +		'<TH width="26%">'+rowtitle+' Reagents</TD>';
	html = html +		'<TH width="10%"></TD>';
	//html = html +		'<TH width="10%">Description</TD>';
	html = html +		'<TH width="10%"></TD>';
	html = html +		'<TH width="10%"></TD>';
	html = html +		'<TH width="10%"></TD>';
	html = html +		'<TH width="10%"></TD>';
	html = html +		'<TH width="10%"></TD>';
	html = html +	'</TR>';
	
	if(blockId == "DNAExtraction"){
		var MagMaxreagobj = recobj.raw.magmaxreagents;
		var reaghtml = PgxDnaExtractionProcess(blockId, MagMaxreagobj, 'MagMAXReag');		
		html = html + reaghtml;
	}else if(blockId == "SNP"){
		var rec = outputList.findRecord('pno', 100, 0, false, false, true);
		
		var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
		var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value
		if (selectpgxsnpopenarrayInstValue.indexOf('OpenArray') != -1){
			var openTargetArray = selectpgxsnpopenarrayInstValue.split("-")[1];
			var targetArray = openTargetArray.split(" ")[0];
			var pgxsnpsample = Ext.get('no_of_pgxsamples').dom.value;
			var pgxsamplecalctype = Ext.get("pgxsamplecombobox").dom;
			var selectpgxsampleObjValue = pgxsamplecalctype.options[pgxsamplecalctype.selectedIndex].value;
			var no_of_reagentsmonths = Ext.get("no_of_reagentsmonths").dom.value;
			pgxsnpsample = pgxsnpsample * no_of_reagentsmonths;
			
			
			var openRec = outputList.findRecord('pno', 7, 0, false, false, true);
			
			var CostPerUnit = pricelist.findRecord('partnumber', openRec.get('partnumber')).regions().findRecord('region', region + "-" + currency).get('price');
			
			var html1 = PgxSnpCnvProcess( false, 1, blockId, 'MagMAXReag', openRec.get('format'), openRec.get('partnumber'), openRec.get('noofunits'), CostPerUnit);
			
			html = html + html1;
			
			var CostPerUnit = pricelist.findRecord('partnumber', openRec.get('mastermixpartnumber')).regions().findRecord('region', region + "-" + currency).get('price');
			
			var html2 = PgxSnpCnvProcess( false, 2, blockId, 'MagMAXReag', openRec.get('mastermix'), openRec.get('mastermixpartnumber'), openRec.get('mnoofunits'), CostPerUnit);
			html = html + html2;
		} else {
			var html1 = PgxSnpCnvProcess( false, 1, blockId, 'MagMAXReag', rec.get('format'), rec.get('partnumber'), rec.get('noofunits'), rec.get('assayscostperunit'));
			html = html + html1;
			
			var html2 = PgxSnpCnvProcess( false, 2, blockId, 'MagMAXReag', rec.get('mastermix'), rec.get('mastermixpartnumber'), rec.get('mnoofunits'), rec.get('mastermixcostperunit'));
			html = html + html2;
		}
	}else if(blockId == "CNV"){
		var rec = outputList.findRecord('pno', 101, 0, false, false, true);
		var html1 = PgxSnpCnvProcess(false, 1, blockId, 'MagMAXReag', rec.get('format'), rec.get('partnumber'), rec.get('noofunits'), rec.get('assayscostperunit'));
		html = html + html1;
		
		var html2 = PgxSnpCnvProcess(true, 2, blockId, 'MagMAXReag', rec.get('refassayname'), rec.get('refassaypartnumber'), rec.get('refassayqty'), rec.get('refassaypercost'));
		html = html + html2;
		
		var html3 = PgxSnpCnvProcess(false, 3, blockId, 'MagMAXReag', rec.get('mastermix'), rec.get('mastermixpartnumber'), rec.get('mnoofunits'), rec.get('mastermixcostperunit'));
		html = html + html3;
	}
	html = html +'</TABLE>';
	
	return html;

}
function showdetailQuote(){
	var blocklist = [{key:"DnaExtractionDiv", value:"DNAExtraction"}, {key:"SNPAnalysisDiv", value:"SNP"}, {key:"CNVAnalysisDiv", value:"CNV"}];  
	var regagentsmonts = Ext.get('no_of_reagentsmonths').dom.value;
	var recobj = null;
	for(var bi=0; bi < blocklist.length; bi++){
		recobj = null;
		if(blocklist[bi].value == "DNAExtraction"){
			recobj = getPgxExtractionRecord(regagentsmonts, blocklist[bi].value);
			var html = createpgxDNAtable(blocklist[bi].value, recobj, 'MagMax');
		}else if(blocklist[bi].value == "SNP"){
			var html = createpgxDNAtable(blocklist[bi].value, outputList, 'SNP' );
		}else if(blocklist[bi].value == "CNV"){
			//addPgxCNV();
			var html = createpgxDNAtable(blocklist[bi].value, outputList, 'CNV' );
		}
		var temid = "#"+blocklist[bi].key;
		$(temid).html(html);
		temid = "";
		html = "";
	}
	createPGxSpinner();
	$('.pgxdiscspinner').val(0);
	//clearTable('pgsInputdeatils');
	
}
function createPGxSpinner(){
	$( ".pgxQtyspinner" ).spinner({ min: 0, max: 1000, step: 1});
	$( ".pgxQtyspinner" ).on('keyup', function(){
		calculationdetailquotes(this.id);
	});
	$( ".pgxQtyspinner" ).on('click', function(){
			$("#"+this.id).focus();
	});
	$( ".pgxdiscspinner" ).spinner({ min: 0, max: 100, step: 0.5});
	$( ".pgxdiscspinner" ).on('keyup', function(){
		calculationdetailquotes(this.id);
	});
	$( ".pgxdiscspinner" ).on('click', function(){
			$("#"+this.id).focus();
	});
	toactivepgxspinner(); 
}
function toactivepgxspinner(){
	$('.ui-spinner-button').click(function() {                       
		$(this).siblings('input').change();
	});
	$('.pgxQtyspinner').spinner().change(function(){
			calculationdetailquotes(this.id);
     });
	 $('.pgxdiscspinner').spinner().change(function(){
			calculationdetailquotes(this.id);
     });
}
function calculationdetailquotes(currentId){
	var currencyValue = currencyMap[region + "-" + currency];
	var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
	var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
	
	var currentIdFirstIndex = currentId.split("_")[0];
	var currentIdLastIndex = currentId.split("_")[2];

	var unitprice = (Ext.get(currentIdFirstIndex+"_unitprice_"+currentIdLastIndex).dom.innerHTML).split('$')[1].replace(/,/g,'');
	
	var MagMAX_discout = 0;
	if(Ext.get(currentIdFirstIndex+"_discper_"+currentIdLastIndex).dom.value != 0){
		MagMAX_discout = Ext.get(currentIdFirstIndex+"_discper_"+currentIdLastIndex).dom.value;
	}
	var totalQty = Ext.get(currentIdFirstIndex+"_qty_"+currentIdLastIndex).dom.value;
	var tsellpricewithdisc = roundNumber(Number(unitprice) * (1 - (MagMAX_discout / 100)), 2);
	Ext.get(currentIdFirstIndex+"_unitsellprice_"+currentIdLastIndex).dom.innerHTML = convertCurrency(tsellpricewithdisc,  region + "-" + currency);
	var totalamount = roundNumber( (tsellpricewithdisc * totalQty ), 2);
	Ext.get(currentIdFirstIndex+"_totalprice_"+currentIdLastIndex).dom.innerHTML = convertCurrency(totalamount,  region + "-" + currency);
	
	UpdateQuoteSummary();
	
}

function getPgxExtractionRecord(pgxsample, ptype){
	var count = 0;
	var record = null;
	var prevRecord = null;
	PgxInstruExtData.each(function(e) {
		if (Number(e.get('samples')) === Number(pgxsample) && e.get('process') === ptype) {
			record = e;
			return false;
		} else if (Number(e.get('samples')) > Number(pgxsample) && e.get('process') === ptype) {
			/*if (prevRecord)
				record = prevRecord;
			else*/
				record = e;
			return false;
		} else if (PgxInstruExtData.count() - 1 === count) {
			record = e;
			return false;
		}
		count++;
		prevRecord = e;
	});	
	return record;		
}

function PgxSnpInstruments(blockId, id){
	var html = "";
	
	var pgxsnpopenarraycalctypeobj = Ext.get("pgxsnpopenarrayformat").dom;
	var selectpgxsnpopenarrayObjValue = pgxsnpopenarraycalctypeobj.options[pgxsnpopenarraycalctypeobj.selectedIndex].value;
	
	var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom; 
	var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
		
	var qty = Ext.get('pgxsnpqsoavalue').dom.value;
	if (qty == 0){
		qty =1;
	}
	if(selectpgxsnpopenarrayInstValue.indexOf("OpenArray") == 0){
		var formattype = "OpenArray";
	}
		
	var d = 1;	
	PgxSnpInstrumentExtData.each(function (result) {
		if(selectpgxsnpopenarrayObjValue == result.get('instrumenttype') && (selectpgxsnpopenarrayInstValue == result.get('format') || formattype == result.get('format'))){
					var partno = result.get('partnumber');
					var priceunit = pricelist.findRecord('partnumber', partno).regions().findRecord('region', region + "-" + currency).get('price');
					html = html +	'<TD id="'+blockId+'-'+id+'_chk_1"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" checked="checked" id="'+blockId+'-'+id+'_chkbx_1"> </TD>';
					html = html +	'<TD id="'+blockId+'-'+id+'_inst_1"><span style="display: inline-block;" id="'+blockId+'-'+id+'_instrument_1">'+result.get('instrumentname')+'</span></TD>';	
					html = html +	'<TD id="'+blockId+'-'+id+'_pno_1"><span style="display: inline-block;" id="'+blockId+'-'+id+'_partno_1">'+partno+'</span></TD>';
					html = html +	'<TD id="'+blockId+'-'+id+'_quantity_1"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-'+id+'_qty_1" name="" value = "'+qty+'"></TD>';
					html = html +	'<TD id="'+blockId+'-'+id+'_up_1"><span style="display: inline-block;" id="'+blockId+'-'+id+'_unitprice_1">'+convertCurrency(priceunit,  region + "-" + currency)+'</span></TD>';		
					html = html +	'<TD id="'+blockId+'-'+id+'_disc_1"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-'+id+'_discper_1"  name=""></TD>';
					html = html +	'<TD id="'+blockId+'-'+id+'_usp_1"><span style="display: inline-block;" id="'+blockId+'-'+id+'_unitsellprice_1">'+convertCurrency(priceunit,  region + "-" + currency)+'</span></TD>';
					var netamt = 0;
					var currencyValue = currencyMap[region + "-" + currency];
					
					//var unitprice = result.get('listprice').split(currencyValue)[1].replace(/,/g,'');
					var unitprice = result.get('listprice');
					netamt = roundNumber( (qty * Number(priceunit)), 2 );
					html = html +	'<TD id="'+blockId+'-'+id+'_tot_1"><span style="display: inline-block;" id="'+blockId+'-'+id+'_totalprice_1">'+convertCurrency(netamt,  region + "-" + currency)+'</span></TD>';
					html = html +	'</TR>';
				
		} 		
		d++;
	});
	return html;
}

function PgxCnvInstruments(blockId, id){
	var currencyValue = currencyMap[region + "-" + currency];
	var html = "";
	
	var pgxsnpopenarraycalctypeobj = Ext.get("pgxsnpopenarrayformat").dom;
	var selectpgxsnpopenarrayObjValue = pgxsnpopenarraycalctypeobj.options[pgxsnpopenarraycalctypeobj.selectedIndex].value;
	
	var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom; 
	var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
	
	var pgxcnainstrumentsobj = Ext.get("pgxcnainstruments").dom;
	var pgxcnainstrumentsobjValue = pgxcnainstrumentsobj.options[pgxcnainstrumentsobj.selectedIndex].value;
	
	var pgxcnainstrumentsneedtouseobj = Ext.get("pgxcnainstrumentsneedtouse").dom;
	var spgxcnainstrumentsneedtouseobjValue = pgxcnainstrumentsneedtouseobj.options[pgxcnainstrumentsneedtouseobj.selectedIndex].value;
		
	var qty = Ext.get('pgxcnanoofinstruments').dom.value;
	
	if(selectpgxsnpopenarrayInstValue.indexOf("OpenArray") == 0){
		var formattype = "OpenArray";
	}
	if(pgxcnainstrumentsobjValue == "Same instrument as SNP analysis" || pgxcnainstrumentsobjValue == selectpgxsnpopenarrayObjValue){	
		pgxcnainstrumentsobjValue = selectpgxsnpopenarrayObjValue;
		var cnvddlvalue = "Same instrument as SNP analysis";
	}
	
	if(spgxcnainstrumentsneedtouseobjValue == "Same block as SNP analysis" || spgxcnainstrumentsneedtouseobjValue == selectpgxsnpopenarrayInstValue){
		spgxcnainstrumentsneedtouseobjValue = selectpgxsnpopenarrayInstValue;
	}
	var d = 1;	
	PgxCnvInstrumentExtData.each(function (result) {
		if(pgxcnainstrumentsobjValue == result.get('instrumenttype') && spgxcnainstrumentsneedtouseobjValue == result.get('format')){
			var instname = result.get('instrumentname')
			var partno = result.get('partnumber');
			var price = result.get('listprice'); 
			var partnosplitval = partno.match('-');
			var pricesplitval = price.match('-');		 
			
			if(cnvddlvalue == "Same instrument as SNP analysis"){	
				var instrumname = instname.split('#')[0];
				if(partnosplitval == '-'){				
					var pno = partno.split('-')[0];	
					var listprice = pricelist.findRecord('partnumber', pno).regions().findRecord('region', region + "-" + currency).get('price');
				} else {
					var pno = partno;
					var listprice = pricelist.findRecord('partnumber', pno).regions().findRecord('region', region + "-" + currency).get('price');
				}
				/*if(pricesplitval == '-'){
					var listprice = price.split('-')[0];
				} else {
					var listprice = price;
				}*/
			} else if (cnvddlvalue != "Same instrument as SNP analysis") {
				var instrumname = instname.split('#')[1];
				if(partnosplitval == '-'){				
					var pno = partno.split('-')[1];
					var listprice = pricelist.findRecord('partnumber', pno).regions().findRecord('region', region + "-" + currency).get('price');
				} else {
					var pno = partno;
					var listprice = pricelist.findRecord('partnumber', pno).regions().findRecord('region', region + "-" + currency).get('price');
				}
				/*if(pricesplitval == '-'){
					var listprice = price.split('-')[1];
				} else {
					var listprice = price;
				}*/
			} else {
				var pno = partno;
				//var listprice = price;
				var listprice = pricelist.findRecord('partnumber', pno).regions().findRecord('region', region + "-" + currency).get('price');
			} 
			
			html = html +	'<TD id="'+blockId+'-'+id+'_chk_1"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" checked="checked" id="'+blockId+'-'+id+'_chkbx_1"> </TD>';
			html = html +	'<TD id="'+blockId+'-'+id+'_inst_1"><span style="display: inline-block;" id="'+blockId+'-'+id+'_instrument_1">'+instrumname+'</span></TD>';	
			html = html +	'<TD id="'+blockId+'-'+id+'_pno_1"><span style="display: inline-block;" id="'+blockId+'-'+id+'_partno_1">'+pno+'</span></TD>';
			html = html +	'<TD id="'+blockId+'-'+id+'_inst_1"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-'+id+'_qty_1" name="" value = "'+qty+'"></TD>';
			html = html +	'<TD id="'+blockId+'-'+id+'_up_1"><span style="display: inline-block;" id="'+blockId+'-'+id+'_unitprice_1">'+convertCurrency(listprice,  region + "-" + currency)+'</span></TD>';		
			html = html +	'<TD id="'+blockId+'-'+id+'_disc_1"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-'+id+'_discper_1"  name=""></TD>';
			html = html +	'<TD id="'+blockId+'-'+id+'_usp_1"><span style="display: inline-block;" id="'+blockId+'-'+id+'_unitsellprice_1">'+convertCurrency(listprice,  region + "-" + currency)+'</span></TD>';
			var netamt = 0;
			//var unitprice = listprice.split(currencyValue)[1].replace(/,/g,'');
			var unitprice = listprice;
			netamt = roundNumber( (qty * Number(unitprice)), 2 );
			html = html +	'<TD id="'+blockId+'-'+id+'_tot_1"><span style="display: inline-block;" id="'+blockId+'-'+id+'_totalprice_1">'+convertCurrency(netamt,  region + "-" + currency)+'</span></TD>';
			html = html +	'</TR>';
				
		} 		
		d++;
	});
	return html;
}


function PgxDnaExtractionProcess(blockId, MagMaxobj, id){
	var currencyValue = currencyMap[region + "-" + currency];
	var html = "";
	
	var regagentsmonts = Ext.get('no_of_reagentsmonths').dom.value;
	var totaldwmy = Ext.get("hdpgxsampleval").dom.value;
	var no_of_pgxsamples = Ext.get("no_of_pgxsamples").dom.value;
	var dnasamplevalue = Ext.get('pgxdnavalues').dom.value;
	var nFindMin = 0;
	var qty = 0;
	for(var mc = 0; mc < MagMaxobj.length; mc++){
		if( mc%2 == 1 && (mc + 1) != MagMaxobj.length){
			html = html +	'<TR class="P-altrow">';
		}else{
			html = html +	'<TR >';
		}		
		
		if(blockId == "DNAExtraction" && id === "MagMAXCons"){
			html = html +		'<TD id="'+blockId+'-'+id+'_chk_'+mc+'"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" id="'+blockId+'-'+id+'_chkbx_'+mc+'"> </TD>';
		}else{
			html = html +		'<TD id="'+blockId+'-'+id+'_chk_'+mc+'"><input type="checkbox" style="position: relative; margin-left: 5px;" checked="checked" onclick="UpdateQuoteSummary();" id="'+blockId+'-'+id+'_chkbx_'+mc+'"> </TD>';
		}
		html = html +		'<TD id="'+blockId+'-'+id+'_instrument_'+mc+'">'+MagMaxobj[mc].produtname+'</TD>';
		html = html +		'<TD id="'+blockId+'-'+id+'_partno_'+mc+'" >'+MagMaxobj[mc].partnumber+'</TD>';
		//html = html +		'<TD id="'+blockId+'-'+id+'_desc_'+mc+'"></TD>';
		
		qty = 1;
		if(id === "MagMAXCons"){
			var aa = (no_of_pgxsamples / 12 *  regagentsmonts / (Number(MagMaxobj[mc].noofsamples) * Number(MagMaxobj[mc].noofreagents) ));
			qty = Math.ceil(aa);  
		}else if( id === "MagMAXInstru"){
			if(MagMaxobj[mc].type == "Instruments"){
				qty = dnasamplevalue; 
			}else {
				var pgxintallation_needtypeobj = Ext.get("pgxintallation_installneed").dom;
				var selectpgxintallation_needObjValue = pgxintallation_needtypeobj.options[pgxintallation_needtypeobj.selectedIndex].value;
				if( selectpgxintallation_needObjValue != "None"){
					qty = dnasamplevalue;
				}else{
					qty = 1;
				}			
			}
		}else if(id === "MagMAXReag"){
		
			var no_of_pgxsamples = Ext.get("no_of_pgxsamples").dom.value;			
			var pgxsamplecalctype = Ext.get("pgxsamplecombobox").dom;
			var selectpgxsampleObjValue = pgxsamplecalctype.options[pgxsamplecalctype.selectedIndex].value;
			var no_of_reagentsmonths = Ext.get("no_of_reagentsmonths").dom.value;
			
			/*if(selectpgxsampleObjValue == "days"){
				no_of_pgxsamples = no_of_pgxsamples * no_of_reagentsmonths;
			}else if(selectpgxsampleObjValue == "weeks"){
				no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 7);
			}else if(selectpgxsampleObjValue == "months"){
				no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 31);
			}else if(selectpgxsampleObjValue == "years"){
				no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 365);
			}*/
								
			var unitprice = pricelist.findRecord('partnumber', MagMaxobj[mc].partnumber).regions().findRecord('region', region + "-" + currency).get('price');
			if (Number(MagMaxobj[mc].wellsamples) == 500){
				qty = Math.ceil((no_of_pgxsamples * no_of_reagentsmonths)/500);
				var price1 = Math.ceil(qty * unitprice);
			}
			if (Number(MagMaxobj[mc].wellsamples) == 2500){
				qty = Math.ceil((no_of_pgxsamples * no_of_reagentsmonths)/2500);		
				var price2 = Math.ceil(qty * unitprice);	
			}
			
			
			var array = new Array();
			array[0] = price1;
			array[1] = price2 ;
			//array[2] = price3 ;
			var mincost = Math.min.apply(Math, array);
			
			if(mincost == price1){
				$("#dnareagent").val(0);											
			} else if(mincost == price2){ 
				$("#dnareagent").val(1);																			
			} /*else if(mincost == price3){
				$("#dnareagent").val(2);																		
			}*/
		
		}
		//var unitprice = (MagMaxobj[mc].listprice).split('$')[1].replace(/,/g,'');
		var unitprice = pricelist.findRecord('partnumber', MagMaxobj[mc].partnumber).regions().findRecord('region', region + "-" + currency).get('price');
		
		if(blockId == "DNAExtraction" && id === "MagMAXCons"){
			if(nFindMin == 0){
				nFindMin = unitprice;
				updateExperimentInfo("DNAExtraction", blockId+'-'+id+'_chkbx_'+mc);
			}
			if( unitprice < nFindMin ){
				nFindMin =  unitprice;
				updateExperimentInfo("DNAExtraction", blockId+'-'+id+'_chkbx_'+mc);
			}
		}
		//var unitprice = (MagMaxobj[mc].listprice);
		html = html +		'<TD id="'+blockId+'-'+id+'_quantity_'+mc+'"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-'+id+'_qty_'+mc+'" name="" value = "'+qty+'"></TD>';
		html = html +		'<TD id="'+blockId+'-'+id+'_unitprice_'+mc+'">'+convertCurrency(unitprice,  region + "-" + currency)+'</TD>';
		html = html +		'<TD id="'+blockId+'-'+id+'_disc_'+mc+'"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-'+id+'_discper_'+mc+'"  name="MagMAXCons_discper_1"></TD>';
		html = html +		'<TD id="'+blockId+'-'+id+'_unitsellprice_'+mc+'">'+convertCurrency(unitprice,  region + "-" + currency)+'</TD>';
		
		var netamt = 0;
		
		netamt = roundNumber( (qty * Number(unitprice)), 2 );
		
		if(blockId == 'DNAExtraction' && id == 'MagMAXInstru'){
			dnaexttotal = dnaexttotal + netamt;			
		}
		
		
		if(blockId == 'DNAExtraction' && id == 'MagMAXCons'){
			MagMAXConstotal = MagMAXConstotal + netamt;			
		}
		
		if(blockId == 'DNAExtraction' && id == 'MagMAXReag'){
			MagMAXReagtotal = MagMAXReagtotal + netamt;			
		}
		//consureagtotal = convertCurrency(consureagtotal,  region + "-" + currency);
		//console.log(" cons "+MagMAXReagtotal);
		html = html +		'<TD id="'+blockId+'-'+id+'_totalprice_'+mc+'">'+convertCurrency(netamt,  region + "-" + currency)+'</TD>';
		html = html +	'</TR>';
	}
	
	return html;
//uncheckdnareagents();
}

		
function PgxSnpCnvProcess(iscolorneed, rowno, blockId, id, formatname, partnumber, noofunits, costperunit){ 
		var costperunit = pricelist.findRecord('partnumber', partnumber).regions().findRecord('region', region + "-" + currency).get('price');
		var html = '';
		
		if( iscolorneed ){
			html = html +	'<TR class="P-altrow">';
		}else{
			html = html +	'<TR >';
		}
		html = html +		'<TD id="'+blockId+'-'+id+'_chk_'+rowno+'"><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" id="'+blockId+'-'+id+'_chkbx_'+rowno+'" checked="checked"> </TD>';
		html = html +		'<TD id="'+blockId+'-'+id+'_instrument_'+rowno+'">'+formatname+'</TD>';
		html = html +		'<TD id="'+blockId+'-'+id+'_partno_'+rowno+'" >'+partnumber+'</TD>';
		//html = html +		'<TD id="'+blockId+'-'+id+'_desc_'+rowno+'">50 plates</TD>';
		html = html +		'<TD id="'+blockId+'-'+id+'_quantity_'+rowno+'"><input class = "input_tablespinner pgxQtyspinner" id="'+blockId+'-'+id+'_qty_'+rowno+'" name="" value = "'+noofunits+'"></TD>';
		html = html +		'<TD id="'+blockId+'-'+id+'_unitprice_'+rowno+'">'+convertCurrency(costperunit, region + "-" + currency)+'</TD>';
		html = html +		'<TD id="'+blockId+'-'+id+'_disc_'+rowno+'"><input class = "input_tablespinner pgxdiscspinner" value = "0" id="'+blockId+'-'+id+'_discper_'+rowno+'"  name=""></TD>';
		html = html +		'<TD id="'+blockId+'-'+id+'_unitsellprice_'+rowno+'">'+convertCurrency(costperunit, region + "-" + currency)+'</TD>';
		var temptot = noofunits * costperunit;
		
		if(blockId == 'SNP' && id == 'MagMAXInstru'){
			snpintrumentstotal = snpintrumentstotal + temptot;			
		}
		if( blockId == 'CNV' && id == 'MagMAXInstru'){
			cnvintrumentstotal = cnvintrumentstotal + temptot;			
		}
		if(blockId == 'SNP' && id == 'MagMAXReag'){
			SNPreagtotal = SNPreagtotal + temptot;			
		}
		if(blockId == 'CNV' && id == 'MagMAXReag'){
			CNVreagtotal = CNVreagtotal + temptot;			
		}
		snpcnvintrumentstotal = snpintrumentstotal + cnvintrumentstotal;
		
		
		html = html +		'<TD id="'+blockId+'-'+id+'_totalprice_'+rowno+'">'+convertCurrency(temptot, region + "-" + currency)+'</TD>';
		html = html +	'</TR>';
		html = html +	'<TR>';
		
		return html;
}


function showmore(){ 	
	$('#display').val('more');
	var display = $("#display").val();
	IntrumentsTrainingTable(display);
	$('#showlessimg').show();	
	$('#showmoreimg').hide();
}
 
function showless() {	
	$('#display').val('less');
	var display = $("#display").val();
	IntrumentsTrainingTable(display);
	$('#showmoreimg').show();	
	$('#showlessimg').hide();
}
 
function IntrumentsTrainingTable(display){
	
		
	var pgxsnpopenarraycalctypeobj = Ext.get("pgxsnpopenarrayformat").dom;
	var selectpgxsnpopenarrayObjValue = pgxsnpopenarraycalctypeobj.options[pgxsnpopenarraycalctypeobj.selectedIndex].value;	
	
	var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
	var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
	
	var pgxcnvopenarraycalctypeobj = Ext.get("pgxcnainstruments").dom;
	var selectpgxcnvopenarrayObjValue = pgxcnvopenarraycalctypeobj.options[pgxcnvopenarraycalctypeobj.selectedIndex].value;		
	
	var pgxcnvinstrucalctypeobj = Ext.get("pgxcnainstrumentsneedtouse").dom;
	var selectpgxcnvInstValue = pgxcnvinstrucalctypeobj.options[pgxcnvinstrucalctypeobj.selectedIndex].value;

	var pgxintallation_maintenanceobj = Ext.get("pgxintallation_maintenance").dom;
	var selectpgxintallation_maintenanceObjValue = pgxintallation_maintenanceobj.options[pgxintallation_maintenanceobj.selectedIndex].value;
	
	var snpinstrument = selectpgxsnpopenarrayObjValue;
	var snpformat = selectpgxsnpopenarrayInstValue;
	var cnvinstrument = selectpgxcnvopenarrayObjValue;
	var cnvformat = selectpgxcnvInstValue;
	
	var SNPService ='';
	var SNPTraining ='';
	var CNVService ='';
	var CNVTraining ='';
	
	
	if(selectpgxintallation_maintenanceObjValue == "None"){
		var SNPServiceMsg = "Did not select any Service plan";
		var CNVServiceMsg = "Did not select any Service plan";
	}

	var html ='';
	html = html +'<TABLE border="0" style="font-size:13px;" id="Training_Table">';
	html = html +	'<TR>';	
	html = html +			'<TH width="4%"></TH>';
	html = html +			'<TH width="26%">'+selectpgxsnpopenarrayObjValue+'</TH>';
	html = html +			'<TH width="15%">P/N</TH>';	
	html = html +			'<TH width="10%">Qty</TH>';
	html = html +			'<TH width="10%">Unit List Price</TH>';
	html = html +			'<TH width="10%">% discount</TH>';
	html = html +			'<TH width="10%">Unit Sell Price</TH>';
	html = html +			'<TH width="10%">Total Sell Price</TH>';	
	html = html +	'</TR>';	
	
	
	// IQ/OQ/IPV
	//Installation Instrument section
	if(cnvinstrument == "Same instrument as SNP analysis" && cnvformat == "Same block as SNP analysis" || cnvinstrument == snpinstrument &&  cnvformat == snpformat){
		html = html + SameInstrumentSameFormat();
	} else if (cnvinstrument == "Same instrument as SNP analysis" && cnvformat != "Same block as SNP analysis"){
		if(cnvformat == snpformat){
			html = html + SameInstrumentSameFormat();
		} else {
			html = html + SameInstrumentDifferentFormat();
		}
	} else if(cnvinstrument != "Same instrument as SNP analysis"){		
		if(cnvinstrument != snpinstrument){
			if(cnvformat == "Same block as SNP analysis"){
				html = html + DifferentInstrumentSameFormatSnp();
			} else if (snpformat == cnvformat){
				html = html + DifferentInstrumentSameFormatSnp();
			} else if (cnvformat != snpformat){	
				html = html + DifferentInstrumentDifferentFormatSnp();
			} else if (cnvinstrument == snpinstrument &&  cnvformat != snpformat){
				html = html + SameInstrumentDifferentFormat();
			} 
		} else if (cnvinstrument == snpinstrument &&  cnvformat != snpformat){
			html = html + SameInstrumentDifferentFormat();
		} 
	} 
	
	var pgxcnvopenarraycalctypeobj = Ext.get("pgxcnainstruments").dom;
	var selectpgxcnvopenarrayObjValue = pgxcnvopenarraycalctypeobj.options[pgxcnvopenarraycalctypeobj.selectedIndex].value;	
	
		
	// SNP Service
	
	if(selectpgxcnvopenarrayObjValue == "Same instrument as SNP analysis" || selectpgxcnvopenarrayObjValue == selectpgxsnpopenarrayObjValue){
		var qty = 2
	} else {
		var qty =1;
	}
	var snpServiceQty = Ext.get("pgxsnpqsoavalue").dom.value;
	
	var count=1;
	if(selectpgxintallation_maintenanceObjValue != "None"){
		PgxServiceExtData.each(function (result) {
			var display = $("#display").val();
			if (display == "less"){				
				if(selectpgxsnpopenarrayObjValue  == result.get('instrument') && selectpgxintallation_maintenanceObjValue == result.get('servicetype')){					
					var SNPserviceplan = result.get('service');
					var SNPserviceplanpartno = result.get('partno');
					//var SNPserviceplanprice = result.get('price');	
					var SNPserviceplanprice = pricelist.findRecord('partnumber', SNPserviceplanpartno).regions().findRecord('region', region + "-" + currency).get('price');						
					html = html +	'<TR>';	
					html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary()" checked="checked" id="SNP-Service_chkbx_1"> </TD>';
					html = html +	'<TD><span style="display: inline-block;" id="SNPserviceplan">'+SNPserviceplan+'</span></TD>';	
					html = html +	'<TD><span style="display: inline-block;" id="SNPserviceplanpartno">'+SNPserviceplanpartno+'</span></TD>';
					html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="SNPservice_qty_1" name="" value = "'+snpServiceQty+'"></TD>';
					html = html +	'<TD><span style="display: inline-block;" id="SNPservice_unitprice_1">'+convertCurrency(SNPserviceplanprice, region + "-" + currency)+'</span></TD>';		
					html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="SNPservice_discper_1"  name=""></TD>';
					html = html +	'<TD><span style="display: inline-block;" id="SNPservice_unitsellprice_1">'+convertCurrency(SNPserviceplanprice, region + "-" + currency)+'</span></TD>';
					SNPserviceplanprice = SNPserviceplanprice * snpServiceQty;					
					html = html +	'<TD><span style="display: inline-block;" id="SNPservice_totalprice_1">'+convertCurrency(SNPserviceplanprice, region + "-" + currency)+'</span></TD>';
					html = html +	'</TR>';
				}
			} else if(display == "more"){				
				if(selectpgxsnpopenarrayObjValue == result.get('instrument')){					
					var SNPserviceplan = result.get('service');
					var SNPserviceplanpartno = result.get('partno');
					//var SNPserviceplanprice = result.get('price');	
					var SNPserviceplanprice = pricelist.findRecord('partnumber', SNPserviceplanpartno).regions().findRecord('region', region + "-" + currency).get('price');	
					if(selectpgxintallation_maintenanceObjValue == result.get('servicetype')){
						var checked = "checked=checked";
					} 
					html = html +	'<TR>';	
					html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary()" '+checked+' id="SNP-Service_chkbx_1"> </TD>';
					html = html +	'<TD><span style="display: inline-block;" id="SNPserviceplan">'+SNPserviceplan+'</span></TD>';	
					html = html +	'<TD><span style="display: inline-block;" id="SNPserviceplanpartno">'+SNPserviceplanpartno+'</span></TD>';
					html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="SNPservice_qty_1" name="" value = "'+snpServiceQty+'"></TD>';
					html = html +	'<TD><span style="display: inline-block;" id="SNPservice_unitprice_1">'+convertCurrency(SNPserviceplanprice, region + "-" + currency)+'</span></TD>';		
					html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="SNPservice_discper_1"  name=""></TD>';
					html = html +	'<TD><span style="display: inline-block;" id="SNPservice_unitsellprice_1">'+convertCurrency(SNPserviceplanprice, region + "-" + currency)+'</span></TD>';
					SNPserviceplanprice = SNPserviceplanprice * snpServiceQty;
					html = html +	'<TD><span style="display: inline-block;" id="SNPservice_totalprice_1">'+convertCurrency(SNPserviceplanprice, region + "-" + currency)+'</span></TD>';
					html = html +	'</TR>';
				}
			} 			
			count++;
		});
				
	} else {
		html = html +	'<TR>';	
		html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary()" checked="checked" id="SNP-Service_chkbx_1"> </TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPserviceplan">'+SNPServiceMsg+'</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan1">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan2">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan3">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan4">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan5">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNP-Service_totalprice_1">-</span></TD>';
		html = html +	'</TR>';		
	}
	
	if(selectpgxcnvopenarrayObjValue != "Same instrument as SNP analysis"){
		if(selectpgxsnpopenarrayObjValue != selectpgxcnvopenarrayObjValue ){
			// Installation Instrument
			html = html +	'<TR>';	
			html = html +			'<TH width="4%"> </TH>';
			html = html +			'<TH width="26%">'+selectpgxcnvopenarrayObjValue+'</TH>';
			html = html +			'<TH width="15%"></TH>';	
			html = html +			'<TH width="10%"></TH>';
			html = html +			'<TH width="10%"></TH>';
			html = html +			'<TH width="10%"></TH>';
			html = html +			'<TH width="10%"></TH>';
			html = html +			'<TH width="10%"></TH>';	
			html = html +	'</TR>';		
			
			var pgxsnpopenarraycalctypeobj = Ext.get("pgxsnpopenarrayformat").dom;
			var snpinstrument = pgxsnpopenarraycalctypeobj.options[pgxsnpopenarraycalctypeobj.selectedIndex].value;				
			
			var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
			var snpformat = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
		
			var pgxcnvopenarraycalctypeobj = Ext.get("pgxcnainstruments").dom;
			var cnvinstrument = pgxcnvopenarraycalctypeobj.options[pgxcnvopenarraycalctypeobj.selectedIndex].value;	
			
			var pgxcnvinstrucalctypeobj = Ext.get("pgxcnainstrumentsneedtouse").dom;
			var cnvformat = pgxcnvinstrucalctypeobj.options[pgxcnvinstrucalctypeobj.selectedIndex].value;
			
			if(cnvinstrument != snpinstrument){	
				if(cnvformat == "Same block as SNP analysis"){						
					html = html + DifferentInstrumentSameFormatCnv();
				} else if (snpformat == cnvformat){
					html = html + DifferentInstrumentSameFormatCnv();
				} else if (cnvformat != snpformat){
					html = html + DifferentInstrumentDifferentFormatCnv();
				}
			}
			
			// CNV Service
			var cnvServiceQty = Ext.get("pgxcnanoofinstruments").dom.value;
			
			if(selectpgxintallation_maintenanceObjValue != "None"){
				PgxServiceExtData.each(function (result) {
					var display = $("#display").val();
					if (display == "less"){	
						if(selectpgxcnvopenarrayObjValue == result.get('instrument') && selectpgxintallation_maintenanceObjValue == result.get('servicetype')){					
							var CNVserviceplan = result.get('service');
							var CNVserviceplanpartno = result.get('partno');
							//var CNVserviceplanprice = result.get('price');	
							var CNVserviceplanprice = pricelist.findRecord('partnumber', CNVserviceplanpartno).regions().findRecord('region', region + "-" + currency).get('price');

							html = html +	'<TR>';	
							html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary()" checked="checked" id="CNV-Service_chkbx_1"> </TD>';
							html = html +	'<TD><span style="display: inline-block;" id="CNVserviceplan">'+CNVserviceplan+'</span></TD>';	
							html = html +	'<TD><span style="display: inline-block;" id="CNVserviceplanpartno">'+CNVserviceplanpartno+'</span></TD>';
							html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="CNVservice_qty_1" name="" value = '+cnvServiceQty+'></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="CNVservice_unitprice_1">'+convertCurrency(CNVserviceplanprice, region + "-" + currency)+'</span></TD>';		
							html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="CNVservice_discper_1"  name=""></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="CNVservice_unitsellprice_1">'+convertCurrency(CNVserviceplanprice, region + "-" + currency)+'</span></TD>';
							CNVserviceplanprice = CNVserviceplanprice * cnvServiceQty;
							html = html +	'<TD><span style="display: inline-block;" id="CNVservice_totalprice_1">'+convertCurrency(CNVserviceplanprice, region + "-" + currency)+'</span></TD>';
							html = html +	'</TR>';
						}
					} else if(display == "more"){
						if(selectpgxcnvopenarrayObjValue == result.get('instrument')){					
							var CNVserviceplan = result.get('service');
							var CNVserviceplanpartno = result.get('partno');
							//var CNVserviceplanprice = result.get('price');	
							var CNVserviceplanprice = pricelist.findRecord('partnumber', CNVserviceplanpartno).regions().findRecord('region', region + "-" + currency).get('price');
							if(selectpgxintallation_maintenanceObjValue == result.get('servicetype')){
								var checked = "checked=checked";
							}
							html = html +	'<TR>';	
							html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary()" '+checked+' id="CNV-Service_chkbx_1"> </TD>';
							html = html +	'<TD><span style="display: inline-block;" id="CNVserviceplan">'+CNVserviceplan+'</span></TD>';	
							html = html +	'<TD><span style="display: inline-block;" id="CNVserviceplanpartno">'+CNVserviceplanpartno+'</span></TD>';
							html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="CNVservice_qty_1" name="" value = '+cnvServiceQty+'></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="CNVservice_unitprice_1">'+convertCurrency(CNVserviceplanprice, region + "-" + currency)+'</span></TD>';		
							html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="CNVservice_discper_1"  name=""></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="CNVservice_unitsellprice_1">'+convertCurrency(CNVserviceplanprice, region + "-" + currency)+'</span></TD>';
							CNVserviceplanprice = CNVserviceplanprice * cnvServiceQty;
							html = html +	'<TD><span style="display: inline-block;" id="CNVservice_totalprice_1">'+convertCurrency(CNVserviceplanprice, region + "-" + currency)+'</span></TD>';
							html = html +	'</TR>';
						}
					}
				});
			} else {
				html = html +	'<TR>';	
				html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary()" checked="checked" id="CNV-Service_chkbx_1"> </TD>';
				html = html +	'<TD><span style="display: inline-block;" id="CNVTrainingplan">'+CNVServiceMsg+'</span></TD>';
				html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan11">-</span></TD>';
				html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan22">-</span></TD>';
				html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan33">-</span></TD>';
				html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan44">-</span></TD>';
				html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan55">-</span></TD>';
				html = html +	'<TD><span style="display: inline-block;" id="CNVservice_totalprice_2">-</span></TD>';
				html = html +	'</TR>';		
			}
		}
	}
	//Training section
	html = html + TrainingSection();
		
	html = html +'</TABLE>';
	
	$("#InstallationTrainingDiv").html(html);
	createPGxSpinner();
	
	//displayquotesummary();
	
}

function DifferentInstrumentDifferentFormatCnv(){
	var html='';
		
	var pgxcnvopenarraycalctypeobj = Ext.get("pgxcnainstruments").dom;
	var cnvinstrument = pgxcnvopenarraycalctypeobj.options[pgxcnvopenarraycalctypeobj.selectedIndex].value;		
	
	var pgxcnvinstrucalctypeobj = Ext.get("pgxcnainstrumentsneedtouse").dom;
	var cnvformat = pgxcnvinstrucalctypeobj.options[pgxcnvinstrucalctypeobj.selectedIndex].value;
	
	var pgxintallationinstallneedobj = Ext.get("pgxintallation_installneed").dom;
	var pgxintallationinstallneedValue = pgxintallationinstallneedobj.options[pgxintallationinstallneedobj.selectedIndex].value;
	
	var cnvServiceQty = Ext.get("pgxcnanoofinstruments").dom.value;
	
	var d = 1;
	if(pgxintallationinstallneedValue != 'None'){
		PgxInstallInstrumentExtData.each(function (result) {
			var display = $("#display").val();
			var price = pricelist.findRecord('partnumber', result.get('partnumber')).regions().findRecord('region', region + "-" + currency).get('price');
			if (display == "less"){
				if(pgxintallationinstallneedValue == "IQ/OQ/IPV"){
					if(cnvinstrument == result.get('instrumenttype') && cnvformat == result.get('format')){								
							html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" checked="checked" id="IqOqIpv_chkbx_'+d+'"> </TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
							html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+cnvServiceQty+'></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
							html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							price = price * cnvServiceQty;
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							html = html +	'</TR>';						
					}
				} else {
					if(cnvinstrument == result.get('instrumenttype') && cnvformat == result.get('format') && pgxintallationinstallneedValue == result.get('type')){								
							html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" checked="checked" id="IqOqIpv_chkbx_'+d+'"> </TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
							html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+cnvServiceQty+'></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
							html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							price = price * cnvServiceQty;
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							html = html +	'</TR>';						
					}
				}
			} else if (display == "more"){
				if(cnvinstrument == result.get('instrumenttype') && cnvformat == result.get('format')){
						if(pgxintallationinstallneedValue == result.get('type')){
							var checked = "checked=checked";
						}
						html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" '+checked+' id="IqOqIpv_chkbx_'+d+'"> </TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
						html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+cnvServiceQty+'></TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
						html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
						price = price * cnvServiceQty;
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
						html = html +	'</TR>';
						
				}
			}
		d++;
		});
	}  else {
		html = html +	'<TR>';	
		html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary()" checked="checked" id="preampchk1"> </TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPserviceplan">Did not select any Installation Instrument</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan1">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan2">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan3">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan4">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan5">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNP-Service_totalprice_1">-</span></TD>';
		html = html +	'</TR>';
	}
	return html;
}

function DifferentInstrumentDifferentFormatSnp(){
	var html='';
	var pgxsnpopenarraycalctypeobj = Ext.get("pgxsnpopenarrayformat").dom;
	var snpinstrument = pgxsnpopenarraycalctypeobj.options[pgxsnpopenarraycalctypeobj.selectedIndex].value;	
	
	var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
	var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
	
	var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
	var snpformat = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;	
	
	var pgxintallationinstallneedobj = Ext.get("pgxintallation_installneed").dom;
	var pgxintallationinstallneedValue = pgxintallationinstallneedobj.options[pgxintallationinstallneedobj.selectedIndex].value;
	
	if(selectpgxsnpopenarrayInstValue.indexOf("OpenArray") == 0){
		var formattype = "OpenArray";
	}
	
	var snpServiceQty = Ext.get("pgxsnpqsoavalue").dom.value;
	
	var d = 1;
	if(pgxintallationinstallneedValue != 'None'){
		PgxInstallInstrumentExtData.each(function (result) {
			var display = $("#display").val();
			var price = pricelist.findRecord('partnumber', result.get('partnumber')).regions().findRecord('region', region + "-" + currency).get('price');
			if (display == "less"){
				if(pgxintallationinstallneedValue == "IQ/OQ/IPV"){
					if(snpinstrument == result.get('instrumenttype') && (snpformat == result.get('format') || formattype == result.get('format'))){
							
							html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" checked="checked" id="IqOqIpv_chkbx_'+d+'"> </TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
							html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+snpServiceQty+'></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
							html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							price = price * snpServiceQty;
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							html = html +	'</TR>';
							
					}
				} else {
					if(snpinstrument == result.get('instrumenttype') && (snpformat == result.get('format') || formattype == result.get('format')) && pgxintallationinstallneedValue == result.get('type')){
							
							html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" checked="checked" id="IqOqIpv_chkbx_'+d+'"> </TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
							html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+snpServiceQty+'></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
							html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							price = price * snpServiceQty;
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							html = html +	'</TR>';
							
					}
				}
			} else if (display == "more"){
				if(snpinstrument == result.get('instrumenttype') && (snpformat == result.get('format') || formattype == result.get('format'))){
						if(pgxintallationinstallneedValue == result.get('type')){
							var checked = "checked=checked";
						}
						html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" '+checked+' id="IqOqIpv_chkbx_'+d+'"> </TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
						html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+snpServiceQty+'></TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
						html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
						price = price * snpServiceQty;
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
						html = html +	'</TR>';
						
				}
			}
		d++;
		});
	}  else {
		html = html +	'<TR>';	
		html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary()" checked="checked" id="preampchk1"> </TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPserviceplan">Did not select any Installation Instrument</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan1">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan2">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan3">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan4">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan5">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNP-Service_totalprice_1">-</span></TD>';
		html = html +	'</TR>';
	}
	return html;
}

function DifferentInstrumentSameFormatCnv(){
	var html='';
	var pgxsnpopenarraycalctypeobj = Ext.get("pgxsnpopenarrayformat").dom;
	var snpinstrument = pgxsnpopenarraycalctypeobj.options[pgxsnpopenarraycalctypeobj.selectedIndex].value;	
	
	var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
	var snpformat = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
	
	var pgxcnvopenarraycalctypeobj = Ext.get("pgxcnainstruments").dom;
	var cnvinstrument = pgxcnvopenarraycalctypeobj.options[pgxcnvopenarraycalctypeobj.selectedIndex].value;		
	
	var pgxcnvinstrucalctypeobj = Ext.get("pgxcnainstrumentsneedtouse").dom;
	var cnvformat = pgxcnvinstrucalctypeobj.options[pgxcnvinstrucalctypeobj.selectedIndex].value;
	
	var pgxintallationinstallneedobj = Ext.get("pgxintallation_installneed").dom;
	var pgxintallationinstallneedValue = pgxintallationinstallneedobj.options[pgxintallationinstallneedobj.selectedIndex].value;
	
	if(cnvformat == snpformat || cnvformat == "Same block as SNP analysis"){
		cnvformat = snpformat;
	}
	var cnvServiceQty = Ext.get("pgxcnanoofinstruments").dom.value;
	var d = 1;
	if(pgxintallationinstallneedValue != 'None'){
		PgxInstallInstrumentExtData.each(function (result) {
			var display = $("#display").val();
			var price = pricelist.findRecord('partnumber', result.get('partnumber')).regions().findRecord('region', region + "-" + currency).get('price');
			if (display == "less"){
				if(pgxintallationinstallneedValue == "IQ/OQ/IPV"){
					if(cnvinstrument == result.get('instrumenttype') && cnvformat == result.get('format')){
							
							html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" checked="checked" id="IqOqIpv_chkbx_'+d+'"> </TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
							html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+cnvServiceQty+'></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
							html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							price = price * cnvServiceQty;
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							html = html +	'</TR>';
							
					}
				} else {
					if(cnvinstrument == result.get('instrumenttype') && cnvformat == result.get('format') && pgxintallationinstallneedValue == result.get('type')){
							
							html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" checked="checked" id="IqOqIpv_chkbx_'+d+'"> </TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
							html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+cnvServiceQty+'></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
							html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							price = price * cnvServiceQty;
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							html = html +	'</TR>';
							
					}
				}
			} else if (display == "more"){
				if(cnvinstrument == result.get('instrumenttype') && cnvformat == result.get('format')){
						if(pgxintallationinstallneedValue == result.get('type')){
							var checked = "checked=checked";
						}						
						html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" '+checked+' id="IqOqIpv_chkbx_'+d+'"> </TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
						html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+cnvServiceQty+'></TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
						html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
						price = price * cnvServiceQty;
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
						html = html +	'</TR>';
						
				}
			}
		d++;
		});
	}  else {
		html = html +	'<TR>';	
		html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary()" checked="checked" id="preampchk1"> </TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPserviceplan">Did not select any Installation Instrument</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan1">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan2">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan3">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan4">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan5">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNP-Service_totalprice_1">-</span></TD>';
		html = html +	'</TR>';
	}
	return html;
}

function DifferentInstrumentSameFormatSnp(){
	var html='';
	var pgxsnpopenarraycalctypeobj = Ext.get("pgxsnpopenarrayformat").dom;
	var snpinstrument = pgxsnpopenarraycalctypeobj.options[pgxsnpopenarraycalctypeobj.selectedIndex].value;	
	
	var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
	var snpformat = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
	
	var pgxcnvopenarraycalctypeobj = Ext.get("pgxcnainstruments").dom;
	var cnvinstrument = pgxcnvopenarraycalctypeobj.options[pgxcnvopenarraycalctypeobj.selectedIndex].value;		
	
	var pgxcnvinstrucalctypeobj = Ext.get("pgxcnainstrumentsneedtouse").dom;
	var cnvformat = pgxcnvinstrucalctypeobj.options[pgxcnvinstrucalctypeobj.selectedIndex].value;
	
	var pgxintallationinstallneedobj = Ext.get("pgxintallation_installneed").dom;
	var pgxintallationinstallneedValue = pgxintallationinstallneedobj.options[pgxintallationinstallneedobj.selectedIndex].value;
	
	if(cnvformat == snpformat || cnvformat == "Same block as SNP analysis"){
		cnvformat = snpformat;
	}
	var snpServiceQty = Ext.get("pgxsnpqsoavalue").dom.value;
	var d = 1;
	if(pgxintallationinstallneedValue != 'None'){
		PgxInstallInstrumentExtData.each(function (result) {
			var display = $("#display").val();
			var price = pricelist.findRecord('partnumber', result.get('partnumber')).regions().findRecord('region', region + "-" + currency).get('price');
			if (display == "less"){
				if(pgxintallationinstallneedValue == "IQ/OQ/IPV"){
					if(snpinstrument == result.get('instrumenttype') && cnvformat == result.get('format')){
							
							html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" checked="checked" id="IqOqIpv_chkbx_'+d+'"> </TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
							html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+snpServiceQty+'></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
							html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							price = price * snpServiceQty;
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							html = html +	'</TR>';
							
					}
				} else {
					if(snpinstrument == result.get('instrumenttype') && cnvformat == result.get('format') && pgxintallationinstallneedValue == result.get('type')){
							
							html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" checked="checked" id="IqOqIpv_chkbx_'+d+'"> </TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
							html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+snpServiceQty+'></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
							html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							price = price * snpServiceQty;
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							html = html +	'</TR>';
							
					}
				}
			} else if (display == "more"){
					if(snpinstrument == result.get('instrumenttype') && cnvformat == result.get('format')){
						if(pgxintallationinstallneedValue == result.get('type')){
							var checked = 'checked=checked';
						}
						html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" '+checked+' id="IqOqIpv_chkbx_'+d+'"> </TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
						html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+snpServiceQty+'></TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
						html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
						price = price * snpServiceQty;
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
						html = html +	'</TR>';
						
				}
			}
		d++;
		});
	}  else {
		html = html +	'<TR>';	
		html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary()" checked="checked" id="preampchk1"> </TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPserviceplan">Did not select any Installation Instrument</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan1">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan2">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan3">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan4">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan5">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNP-Service_totalprice_1">-</span></TD>';
		html = html +	'</TR>';
	}
	return html;
}

function SameInstrumentSameFormat(){
	var html ='';
	var pgxsnpopenarraycalctypeobj = Ext.get("pgxsnpopenarrayformat").dom;
	var selectpgxsnpopenarrayObjValue = pgxsnpopenarraycalctypeobj.options[pgxsnpopenarraycalctypeobj.selectedIndex].value;
	
	var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
	var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
	
	var pgxintallationinstallneedobj = Ext.get("pgxintallation_installneed").dom;
	var pgxintallationinstallneedValue = pgxintallationinstallneedobj.options[pgxintallationinstallneedobj.selectedIndex].value;
	
	var snpServiceQty = Ext.get("pgxsnpqsoavalue").dom.value;
	var d = 1;
	if(pgxintallationinstallneedValue != 'None'){
		PgxInstallInstrumentExtData.each(function (result) {
			var display = $("#display").val();
			var price = pricelist.findRecord('partnumber', result.get('partnumber')).regions().findRecord('region', region + "-" + currency).get('price');
			if (display == "less"){
				if(pgxintallationinstallneedValue == "IQ/OQ/IPV"){
					if(selectpgxsnpopenarrayObjValue == result.get('instrumenttype') && selectpgxsnpopenarrayInstValue == result.get('format')){
							var listprice = pricelist.findRecord('partnumber', result.get('partnumber')).regions().findRecord('region', region + "-" + currency).get('price');						
							listprice = listprice * snpServiceQty; 
							listprice = convertCurrency(listprice, region + "-" + currency); 
							html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" checked="checked" id="IqOqIpv_chkbx_'+d+'"> </TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
							html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+snpServiceQty+'></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
							html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+listprice+'</span></TD>';
							html = html +	'</TR>';
							
					}
				} else {
					if(selectpgxsnpopenarrayObjValue == result.get('instrumenttype') && selectpgxsnpopenarrayInstValue == result.get('format') && pgxintallationinstallneedValue == result.get('type')){
							var listprice = pricelist.findRecord('partnumber', result.get('partnumber')).regions().findRecord('region', region + "-" + currency).get('price');						
							listprice = listprice * snpServiceQty; 
							listprice = convertCurrency(listprice, region + "-" + currency); 
							html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" checked="checked" id="IqOqIpv_chkbx_'+d+'"> </TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
							html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+snpServiceQty+'></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
							html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+listprice+'</span></TD>';
							html = html +	'</TR>';
							
					} 	
				}
			} else if (display == "more"){
				if(selectpgxsnpopenarrayObjValue == result.get('instrumenttype') && selectpgxsnpopenarrayInstValue == result.get('format')){
						if(pgxintallationinstallneedValue == result.get('type')){
							var checked = "checked=checked";
						}
						var listprice = pricelist.findRecord('partnumber', result.get('partnumber')).regions().findRecord('region', region + "-" + currency).get('price');
						listprice = listprice * snpServiceQty; 
						listprice = convertCurrency(listprice, region + "-" + currency); 
						html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" '+checked+' id="IqOqIpv_chkbx_'+d+'"> </TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
						html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+snpServiceQty+'></TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
						html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
						
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+listprice+'</span></TD>';
						html = html +	'</TR>';
						
				} 	
			}
		d++;
		});
	}  else {
		html = html +	'<TR>';	
		html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary()" checked="checked" id="preampchk1"> </TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPserviceplan">Did not select any Installation Instrument</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan1">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan2">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan3">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan4">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan5">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNP-Service_totalprice_1">-</span></TD>';
		html = html +	'</TR>';
	}
	return html;
}

function SameInstrumentDifferentFormat(){
	var html ='';
	var pgxsnpopenarraycalctypeobj = Ext.get("pgxsnpopenarrayformat").dom;
	var selectpgxsnpopenarrayObjValue = pgxsnpopenarraycalctypeobj.options[pgxsnpopenarraycalctypeobj.selectedIndex].value;
	
	var pgxopenarraycalctypeobj = Ext.get("pgxsnpformatneed").dom;
	var selectpgxsnpopenarrayInstValue = pgxopenarraycalctypeobj.options[pgxopenarraycalctypeobj.selectedIndex].value;
	
	var pgxcnvinstrucalctypeobj = Ext.get("pgxcnainstrumentsneedtouse").dom;
	var selectpgxcnvInstValue = pgxcnvinstrucalctypeobj.options[pgxcnvinstrucalctypeobj.selectedIndex].value;
	
	var pgxintallationinstallneedobj = Ext.get("pgxintallation_installneed").dom;
	var pgxintallationinstallneedValue = pgxintallationinstallneedobj.options[pgxintallationinstallneedobj.selectedIndex].value;
	
	if(selectpgxsnpopenarrayInstValue.indexOf("OpenArray") == 0){
		var formattype = "OpenArray";
	}
	var snpServiceQty = Ext.get("pgxsnpqsoavalue").dom.value;
	var d = 1;
	if(pgxintallationinstallneedValue != 'None'){
		PgxInstallInstrumentExtData.each(function (result) {
			var display = $("#display").val();
			var price = pricelist.findRecord('partnumber', result.get('partnumber')).regions().findRecord('region', region + "-" + currency).get('price');
			if (display == "less"){
				if(pgxintallationinstallneedValue == "IQ/OQ/IPV"){
					if(selectpgxsnpopenarrayObjValue == result.get('instrumenttype') && (selectpgxsnpopenarrayInstValue == result.get('format') || formattype == result.get('format'))){						
							html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" checked="checked" id="IqOqIpv_chkbx_'+d+'"> </TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
							html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+snpServiceQty+'></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
							html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							price = price * snpServiceQty;
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							html = html +	'</TR>';				
					}
				} else {
					if(selectpgxsnpopenarrayObjValue == result.get('instrumenttype') && (selectpgxsnpopenarrayInstValue == result.get('format') || formattype == result.get('format')) && pgxintallationinstallneedValue == result.get('type')){						
							html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" checked="checked" id="IqOqIpv_chkbx_'+d+'"> </TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
							html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+snpServiceQty+'></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
							html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							price = price * snpServiceQty;
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							html = html +	'</TR>';				
					} 
				}
			} else if (display == "more"){
				if(selectpgxsnpopenarrayObjValue == result.get('instrumenttype') && (selectpgxsnpopenarrayInstValue == result.get('format') || formattype == result.get('format'))){
					if(pgxintallationinstallneedValue == result.get('type')){
						var checked = "checked=checked";
					}
					html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" '+checked+' id="IqOqIpv_chkbx_'+d+'"> </TD>';
					html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
					html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
					html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+snpServiceQty+'></TD>';
					html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
					html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
					html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
					price = price * snpServiceQty;
					html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
					html = html +	'</TR>';				
				} 
			}
		d++;
		});
	}  else {
		html = html +	'<TR>';	
		html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary()" checked="checked" id="preampchk1"> </TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPserviceplan">Did not select any Installation Instrument</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan1">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan2">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan3">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan4">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan5">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNP-Service_totalprice_1">-</span></TD>';
		html = html +	'</TR>';
	}

	var pgxcnvinstrucalctypeobj = Ext.get("pgxcnainstrumentsneedtouse").dom;
	var selectpgxcnvInstValue = pgxcnvinstrucalctypeobj.options[pgxcnvinstrucalctypeobj.selectedIndex].value;
	var d = 1;
	var cnvServiceQty = Ext.get("pgxcnanoofinstruments").dom.value;
	if(pgxintallationinstallneedValue != 'None'){
		PgxInstallInstrumentExtData.each(function (result) {
			var display = $("#display").val();
			var price = pricelist.findRecord('partnumber', result.get('partnumber')).regions().findRecord('region', region + "-" + currency).get('price');
			if (display == "less"){
				if(pgxintallationinstallneedValue == "IQ/OQ/IPV"){
					if(selectpgxsnpopenarrayObjValue == result.get('instrumenttype') && selectpgxcnvInstValue == result.get('format')){						
							html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" checked="checked" id="IqOqIpv_chkbx_'+d+'"> </TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
							html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+cnvServiceQty+'></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
							html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							price = price * cnvServiceQty;
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							html = html +	'</TR>';					
					}
				} else {
					if(selectpgxsnpopenarrayObjValue == result.get('instrumenttype') && selectpgxcnvInstValue == result.get('format') && pgxintallationinstallneedValue == result.get('type')){						
							html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" checked="checked" id="IqOqIpv_chkbx_'+d+'"> </TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
							html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+cnvServiceQty+'></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
							html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							price = price * cnvServiceQty;
							html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
							html = html +	'</TR>';					
					}
				}
			} else if (display == "more"){
				if(selectpgxsnpopenarrayObjValue == result.get('instrumenttype') && selectpgxcnvInstValue == result.get('format')){	
					if(pgxintallationinstallneedValue == result.get('type')){
						var checked = "checked=checked";
					}
						html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary();" '+checked+' id="IqOqIpv_chkbx_'+d+'"> </TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvdesc'+d+'">'+result.get('description')+'</span></TD>';	
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpvpartno'+d+'">'+result.get('partnumber')+'</span></TD>';
						html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="IqOqIpv_qty_'+d+'" name="" value = '+cnvServiceQty+'></TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';		
						html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = "0" id="IqOqIpv_discper_'+d+'"  name=""></TD>';
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_unitsellprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
						price = price * cnvServiceQty;
						html = html +	'<TD><span style="display: inline-block;" id="IqOqIpv_totalprice_'+d+'">'+convertCurrency(price, region + "-" + currency)+'</span></TD>';
						html = html +	'</TR>';					
				}
			}
		d++;
		});
	}  else {
		html = html +	'<TR>';	
		html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary()" checked="checked" id="preampchk1"> </TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPserviceplan">Did not select any Installation Instrument</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan1">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan2">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan3">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan4">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNPTrainingplan5">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="SNP-Service_totalprice_1">-</span></TD>';
		html = html +	'</TR>';
	}

	return html;
}


function TrainingSection(){
	var html ='';
	// Training section
	var pgxintallation_addtrainingobj = Ext.get("pgxintallation_addtraining").dom;
	var selectpgxintallation_addtrainingObjValue = pgxintallation_addtrainingobj.options[pgxintallation_addtrainingobj.selectedIndex].value;

	html = html +	'<TR>';	
	html = html +			'<TH width="4%"></TH>';
	html = html +			'<TH width="26%">Training</TH>';
	html = html +			'<TH width="15%"></TH>';	
	html = html +			'<TH width="10%"></TH>';
	html = html +			'<TH width="10%"></TH>';
	html = html +			'<TH width="10%"></TH>';
	html = html +			'<TH width="10%"></TH>';
	html = html +			'<TH width="10%"></TH>';	
	html = html +	'</TR>';
	if(selectpgxintallation_addtrainingObjValue != "None"){
		var count = 1;
		PgxTrainingExtData.each(function (record) {				
			var partno = record.get('partnumber');
			var partnosplitval = partno.match('-');		
			var qty = record.get('qty');
			var discount = record.get('discount');
			if(partnosplitval == '-'){
				var partnoval1 = partno.split('-')[0];
				var partnoval2 = partno.split('-')[1];				
				var unitprice = pricelist.findRecord('partnumber', partnoval1).regions().findRecord('region', region + "-" + currency).get('price');
				var totalprice = unitprice;
			} else {
				if(selectpgxintallation_addtrainingObjValue == "Novice Customer Training"){
					if(record.get('title') == "Basic training AND follow up visit - 1 day"){
						var qty = 2;
						//var totalprice = record.get('totalsellprice'); //"$4,000.00";
						var unitprice = pricelist.findRecord('partnumber', partno).regions().findRecord('region', region + "-" + currency).get('price');
						var totalprice = unitprice * qty * (1 - (discount / 100));
					} else {
						var qty = 1;
						//var totalprice = record.get('totalsellprice');//"$4,000.00";
						var unitprice = pricelist.findRecord('partnumber', partno).regions().findRecord('region', region + "-" + currency).get('price');
						var totalprice = unitprice * qty * (1 - (discount / 100));
					}								 
				} else {
					var qty = 1;
					var unitprice = pricelist.findRecord('partnumber', partno).regions().findRecord('region', region + "-" + currency).get('price');
					var totalprice = unitprice * qty * (1 - (discount / 100));
					/*if(record.get('unitsellprice') == "NC"){
						var totalprice = "NC";
					} else {
						var totalprice = record.get('totalsellprice');
					}*/
				}				
				
			}
			
			if(partno == 'A26745'){
				var checked = "checked";
			} else {
				var checked = "";
			}
			html = html +	'<TR>';	
			html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary()" '+checked+' id="Training_chkbx_'+count+'"> </TD>';
			html = html +	'<TD><span style="display: inline-block;" id="Training_title_'+count+'">'+record.get('title')+'</span></TD>';	
			if(partnosplitval == '-'){
				html = html +	'<TD style="position: relative;"><span style="display: display: inline-block;border-bottom: 1px solid #DBDBDE;width: 100%;position: absolute;top: 5px;left: 0;text-indent: 8px;" id="Training_pno_'+count+'">'+partnoval1+'</span><span style="display: inline-block;position: absolute;margin-top: 5px;" id="Training_pno2_'+count+'">'+partnoval2+'</span></TD>';
			} else {
				html = html +	'<TD><span style="display: inline-block;" id="Training_pno_'+count+'">'+partno+'</span></TD>';
			}
			html = html +	'<TD><input class = "input_tablespinner pgxQtyspinner" id="Training_qty_'+count+'" name="" value ='+qty+'></TD>';
			
			html = html +	'<TD><span style="display: inline-block;" id="Training_unitprice_'+count+'">'+convertCurrency(unitprice, region + "-" + currency)+'</span></TD>';	
			html = html +	'<TD><input class = "input_tablespinner pgxdiscspinner" value = '+record.get('discount')+' id="Training_discper_'+count+'"  name=""></TD>';
			html = html +	'<TD><span style="display: inline-block;" id="Training_unitsellprice_'+count+'">'+convertCurrency(unitprice, region + "-" + currency)+'</span></TD>';
			html = html +	'<TD><span style="display: inline-block;" id="Training_totalprice_'+count+'">'+convertCurrency(totalprice, region + "-" + currency)+'</span></TD>';
			html = html +	'</TR>';
			count++;
		});
	}
	if(selectpgxintallation_addtrainingObjValue == "None"){
		html = html +	'<TR>';	
		html = html +	'<TD><input type="checkbox" style="position: relative; margin-left: 5px;" onclick="UpdateQuoteSummary()" checked="checked" id="Training_chkbx_'+count+'"> </TD>';
		html = html +	'<TD><span style="display: inline-block;" id="Training_title_1">Did not select Training value</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="Training_pno_1">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="Training_qty_1">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="Training_unitsellprice_1">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="Training_discper_1">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="Training_unitsellprice_1">-</span></TD>';
		html = html +	'<TD><span style="display: inline-block;" id="Training_totalprice_1">-</span></TD>';
		html = html +	'</TR>';
	}	
	
	return html;
}

function UpdateQuoteSummary(){
	var currencyValue = currencyMap[region + "-" + currency];
	var nEachTotalPrice = 0;
	var nTotalPrice = 0;
	var nCostPerSample = 0;
	if(getExperimentInfo("generateQuoteFor") == "Reagents only"){
		var tableIds ={'DNAExtraction_Table':'quotesummary_DNAExtraction','SNP_Table':'quotesummary_SNP','CNV_Table':'quotesummary_CNV'};
	} else {
		var tableIds ={'DNAExtraction_Table':'quotesummary_DNAExtraction','SNP_Table':'quotesummary_SNP','CNV_Table':'quotesummary_CNV','Service_Table':'quotesummary_service1','Training_Table':'quotesummary_training1'};
	}
	
	//var tableIds ={'DNAExtraction_Table':'quotesummary_DNAExtraction','SNP_Table':'quotesummary_SNP','CNV_Table':'quotesummary_CNV','Service_Table':'quotesummary_service1','Training_Table':'quotesummary_training1'};
	
	$.each(tableIds, function(index,value){
		nEachTotalPrice = 0;
		var searchCondition = "";
		if(value == "quotesummary_service1"){
			index = "Training_Table";
			searchCondition = '[id^="IqOqIpv_"]';
		}else if(value == "quotesummary_training1"){
			searchCondition = '[id^="Training_"]';
		}
		$('#'+index).find('input[type="checkbox"]'+searchCondition+':checked').each(function (e) {
		   var currId = $(this).attr('id');
		   var findIds = currId.split("_");
		   if(findIds.length <= 3){
				var unitId = findIds[0]+'_totalprice_'+findIds[2];
			}else{
				var unitId = findIds[0]+'_totalprice_'+findIds[1];
			}
		   var eachRowPrice = $('#'+unitId).html();
		  // console.log(unitId);
		  // console.log("eachRowPrice : "+ eachRowPrice);
		   if( eachRowPrice == '-' || eachRowPrice == '' || eachRowPrice == ' ' || eachRowPrice == 'undefined'){
				var eachRowPriceNum = 0;
		   }else{
				//var eachRowPriceNum = Number( eachRowPrice.replace(/[^0-9\.]+/g,""));
				var eachRowPriceNum = Number( eachRowPrice.replace('Rs.',"").replace(/[^0-9\.]+/g,""));
		   }
		   //if( unitId.indexOf("MagMAXCons") != -1 || unitId.indexOf("MagMAXReag") != -1 ){
				nCostPerSample = nCostPerSample + eachRowPriceNum;
		   //}
		  
		  if( value === "quotesummary_DNAExtraction" ){
				if( unitId.indexOf("MagMAXInstru") != -1 || unitId.indexOf("MagMAXReag") != -1 ){
					nEachTotalPrice = nEachTotalPrice + eachRowPriceNum;
				}
		  } else if( value != "quotesummary_DNAExtraction" ){
				nEachTotalPrice = nEachTotalPrice + eachRowPriceNum;
		 }
			
		   //console.log(nEachTotalPrice);
		});
		nTotalPrice = nTotalPrice + nEachTotalPrice;
		$("#"+value).html(convertCurrency(nEachTotalPrice,  region + "-" + currency));		
	});
	$("#quotesummary_total1").html(convertCurrency(nTotalPrice,  region + "-" + currency));
	
	/* Cost per sample */
	var pgxsamplecalctype = Ext.get("pgxsamplecombobox").dom;
    var selectpgxsampleObjValue = pgxsamplecalctype.options[pgxsamplecalctype.selectedIndex].value;
	var no_of_reagentsmonths = Ext.get("no_of_reagentsmonths").dom.value;
	var no_of_pgxsamples = Ext.get("no_of_pgxsamples").dom.value;
	
	/*if(selectpgxsampleObjValue == "days"){
		no_of_pgxsamples = no_of_pgxsamples * no_of_reagentsmonths;
	}else if(selectpgxsampleObjValue == "weeks"){
		no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 7);
	}else if(selectpgxsampleObjValue == "months"){
		no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 31);
	}else if(selectpgxsampleObjValue == "years"){
		no_of_pgxsamples = no_of_pgxsamples * (no_of_reagentsmonths * 365);
	}*/
	
	no_of_pgxsamples = no_of_pgxsamples * no_of_reagentsmonths;
	var costpersample = Math.round ( nCostPerSample / no_of_pgxsamples );
	costpersample = convertCurrency(costpersample, region + "-" + currency);
	$("#quotesummary_costpersample1").html(costpersample);
}


function GetQuoteDeliveryInformation(){

	var pgx_delivery_methodval = Ext.get("pgx_delivery_methodcombo").dom.value;
	pgx_delivery_methodval=(pgx_delivery_methodval=='')?"-":pgx_delivery_methodval;
	var pgx_customeby = Ext.get("pgx_customeby_id").dom.value;
	pgx_customeby=(pgx_customeby=='')?"-":pgx_customeby;
	var pgx_salesrepby = Ext.get("pgx_salesrepby_id").dom.value;
	pgx_salesrepby=(pgx_salesrepby=='')?"-":pgx_salesrepby;
	var pgx_account_number = Ext.get("pgx_account_number").dom.value;
	pgx_account_number=(pgx_account_number=='')?"-":pgx_account_number;
	var pgx_original_quote_no = Ext.get("pgx_original_quote_no").dom.value;
	pgx_original_quote_no=(pgx_original_quote_no=='')?"-":pgx_original_quote_no;
	var pgx_attention_to = Ext.get("pgx_attention_to").dom.value;
	pgx_attention_to=(pgx_attention_to=='')?"-":pgx_attention_to;
	var pgx_institution = Ext.get("pgx_institution").dom.value;
	pgx_institution=(pgx_institution=='')?"-":pgx_institution;
	var pgx_department = Ext.get("pgx_department").dom.value;
	pgx_department=(pgx_department=='')?"-":pgx_department;
	var pgx_building = Ext.get("pgx_building").dom.value;
	pgx_building=(pgx_building=='')?"-":pgx_building;
	var pgx_address = Ext.get("pgx_address").dom.value;
	pgx_address=(pgx_address=='')?"-":pgx_address;
	var pgx_city_state = Ext.get("pgx_city_state").dom.value;
	pgx_city_state=(pgx_city_state=='')?"-":pgx_city_state;
	var pgx_zipcode = Ext.get("pgx_zipcode").dom.value;
	pgx_zipcode=(pgx_zipcode=='')?"-":pgx_zipcode;
	var pgx_phone = Ext.get("pgx_phone").dom.value;
	pgx_phone=(pgx_phone=='')?"-":pgx_phone;
	var pgx_extention = Ext.get("pgx_extention").dom.value;
	pgx_extention=(pgx_extention=='')?"-":pgx_extention;
	var pgx_email = Ext.get("pgx_email").dom.value;
	pgx_email=(pgx_email=='')?"-":pgx_email;
	var pgx_fax = Ext.get("pgx_fax").dom.value;
	pgx_fax=(pgx_fax=='')?"-":pgx_fax;
	

	var tabledata ='';
	tabledata += '<TABLE border="1" rules="cols" cellpadding="5">';
	tabledata += "<thead>";
	tabledata += '<TR style="background:rgb(42,128,213)">';
	tabledata = 			'<TH style="color:white">Quote Delivery Information</TH>';	
	tabledata =  '</TR>';	
	tabledata += "</thead>";
	tabledata += "<tbody>";
	tabledata += '<TR>';	
	tabledata += '<TD><span style="width: 400px;display: inline-block;">Delivery Method</span> - <span style="margin-left: 10px;">'+pgx_delivery_methodval+'</span></TD>'
	tabledata += '</TR>';
	tabledata += '<TR>';
	tabledata += '<TD><span style="width: 400px;display: inline-block;">Send to customer by</span> - <span style="margin-left: 10px;">'+pgx_customeby+'</span></TD>'
	tabledata += '</TR>';
	tabledata += '<TR>';
	tabledata += '<TD><span style="width: 400px;display: inline-block;">Send to sales rep by</span> - <span style="margin-left: 10px;">'+pgx_salesrepby+'</span></TD>';
	tabledata += '</TR>';
	tabledata += '<TR>';
	tabledata += '<TD><span style="width: 400px;display: inline-block;">Account number</span> - <span style="margin-left: 10px;">'+
	pgx_account_number+'</span></TD>';
	tabledata += '</TR>';
	tabledata += '<TR>';
	tabledata += '<TD><span style="width: 400px;display: inline-block;">Original quote number (if applicable)</span> - <span style="margin-left: 10px;">'+pgx_original_quote_no+'</span></TD>';
	tabledata += '</TR>';
	tabledata += '<TR>';
	tabledata += '<TD><span style="width: 400px;display: inline-block;">Attention to</span> - <span style="margin-left: 10px;">'+pgx_attention_to+'</span></TD>';
	tabledata += '</TR>';
	tabledata += '<TR>';
	tabledata += '<TD><span style="width: 400px;display: inline-block;">Institution</span> - <span style="margin-left: 10px;">'+pgx_institution+'</span></TD>';
	tabledata += '</TR>';
	tabledata += '<TR>';
	tabledata += '<TD><span style="width: 400px;display: inline-block;">Department</span> - <span style="margin-left: 10px;">'+pgx_department+'</span></TD>';
	tabledata += '</TR>';
	tabledata += '<TR>';
	tabledata += '<TD><span style="width: 400px;display: inline-block;">Building</span> - <span style="margin-left: 10px;">'+pgx_building+'</span></TD>';
	tabledata += '</TR>';
	tabledata += '<TR>';
	tabledata += '<TD><span style="width: 400px;display: inline-block;">Address</span> - <span style="margin-left: 10px;">'+pgx_address+'</span></TD>';
	tabledata += '</TR>';
	tabledata += '<TR>';
	tabledata += '<TD><span style="width: 400px;display: inline-block;">City-State</span> - <span style="margin-left: 10px;">'+pgx_city_state+'</span></TD>';
	tabledata += '</TR>';
	tabledata += '<TR>';
	tabledata += '<TD><span style="width: 400px;display: inline-block;">Zipcode</span> - <span style="margin-left: 10px;">'+pgx_zipcode+'</span></TD>';
	tabledata += '</TR>';
	tabledata += '<TR>';
	tabledata += '<TD><span style="width: 400px;display: inline-block;">Phone</span> - <span style="margin-left: 10px;">'+pgx_phone+'</span></TD>';
	tabledata += '</TR>';
	tabledata += '<TR>';
	tabledata += '<TD><span style="width: 400px;display: inline-block;">Extention</span> - <span style="margin-left: 10px;">'+pgx_extention+'</span></TD>';
	tabledata += '</TR>';
	tabledata += '<TR>';
	tabledata += '<TD><span style="width: 400px;display: inline-block;">E-mail</span> - <span style="margin-left: 10px;">'+pgx_email+'</span></TD>';
	tabledata += '</TR>';
	tabledata += '<TR>';
	tabledata += '<TD><span style="width: 400px;display: inline-block;">Fax</span> - <span style="margin-left: 10px;">'+pgx_fax+'</span></TD>';
	tabledata += '</TR>';
	tabledata += '</tbody></TABLE>';
	
	return tabledata;
}
//
// 