// Change Volume Discounts when Quantity changes 28-02-2014

function miRNAVolDiscount(qty,txtbxpartno){
	if(qty <= 13 ){		
		currentVolumeDiscount = 0;			
	} else if(qty >= 14 && qty <= 20 ){ 
		currentVolumeDiscount = 10;				
	} else if(qty >= 21 && qty <= 100 ){
		currentVolumeDiscount = 20;				
	} else if((qty >= 101) && (qty <= 300)){
		currentVolumeDiscount = 30;				
	} else if(qty > 300){
		currentVolumeDiscount = 35;				
	}
	$("#"+txtbxpartno).html(currentVolumeDiscount);
	return currentVolumeDiscount;
}


function DigitalPCRVolDiscount(qty,txtbxpartno){ 
	if(txtbxpartno == 4458070 || txtbxpartno == 4470184){ 
		if(qty >= 1 && qty <= 5 ){		
			currentVolumeDiscount = 10;						
		} else if(qty >= 6 && qty <= 10 ){ 
			currentVolumeDiscount = 20;					
		} else if(qty >= 11 && qty <= 19 ){
			currentVolumeDiscount = 30;					
		} else if((qty >= 20) && (qty <= 29)){
			currentVolumeDiscount = 40;				
		} else if(qty > 30){
			currentVolumeDiscount = 50;				
		}
		$("#"+txtbxpartno).html(currentVolumeDiscount);
	} else if(txtbxpartno == 4470185 || txtbxpartno == 4460585){ 
		if(qty >= 1 && qty <= 4 ){		
			currentVolumeDiscount = 5;					
		} else if(qty >= 5 && qty <= 9 ){ 
			currentVolumeDiscount = 10;				
		} else if(qty >= 10 && qty <= 14 ){
			currentVolumeDiscount = 15;					
		} else if(qty >= 15){
			currentVolumeDiscount = 20;			
		}
		$("#"+txtbxpartno).html(currentVolumeDiscount);
	}
	return currentVolumeDiscount;
}

function GenoTypingFormat16VolDiscount(qty,txtbxpartno){
	if(qty == 1 ){		
		currentVolumeDiscount = 0;			
	} else if(qty == 2 ){ 
		currentVolumeDiscount = 20;			
	} else if(qty == 3 ){ 
		currentVolumeDiscount = 30;				
	} else if(qty == 4 ){ 
		currentVolumeDiscount = 40;				
	} else if(qty == 5 || qty == 6){ 
		currentVolumeDiscount = 50;				
	} else if(qty >= 7 ){ 
		currentVolumeDiscount = 55;			
	}
	$("#"+txtbxpartno).html(currentVolumeDiscount);
	return currentVolumeDiscount;
}

function GenoTypingFormat32VolDiscount(qty,txtbxpartno){
	if(qty == 1 ){		
		currentVolumeDiscount = 0;					
	} else if(qty == 2 || qty == 3){ 
		currentVolumeDiscount = 20;				
	} else if(qty == 4 ){ 
		currentVolumeDiscount = 30;				
	} else if(qty >= 5 && qty <= 7){ 
		currentVolumeDiscount = 40;				
	} else if(qty >= 8 && qty <= 10){ 
		currentVolumeDiscount = 50;				
	} else if(qty >= 11 ){ 
		currentVolumeDiscount = 55;				
	}
	$("#"+txtbxpartno).html(currentVolumeDiscount);
	return currentVolumeDiscount;
}

function GenoTypingFormat64VolDiscount(qty,txtbxpartno){
	if(qty == 1 || qty == 2){		
		currentVolumeDiscount = 0;			
	} else if(qty == 3){ 
		currentVolumeDiscount = 10;				
	} else if(qty >= 4 && qty <= 8){ 
		currentVolumeDiscount = 20;				
	} else if(qty == 9 || qty == 10){ 
		currentVolumeDiscount = 30;				
	} else if(qty >= 11 && qty <= 15){ 
		currentVolumeDiscount = 40;				
	} else if(qty >= 16 && qty <= 20 ){ 
		currentVolumeDiscount = 50;				
	} else if(qty >= 21 ){ 
		currentVolumeDiscount = 55;				
	}
	$("#"+txtbxpartno).html(currentVolumeDiscount);
	return currentVolumeDiscount;
}

function GenoTypingFormat128VolDiscount(qty,txtbxpartno){
	if(qty <= 4){		
		currentVolumeDiscount = 0;					
	} else if(qty >= 5 && qty <= 8){ 
		currentVolumeDiscount = 10;				
	} else if(qty >= 9 && qty <= 13){ 
		currentVolumeDiscount = 20;				
	} else if(qty >= 14 && qty <= 20){ 
		currentVolumeDiscount = 30;				
	} else if(qty >= 21 && qty <= 30){ 
		currentVolumeDiscount = 40;				
	} else if(qty >= 31 && qty <= 41 ){ 
		currentVolumeDiscount = 50;				
	} else if(qty >= 42 ){ 
		currentVolumeDiscount = 55;				
	}
	$("#"+txtbxpartno).html(currentVolumeDiscount);
	return currentVolumeDiscount;
}

function GenoTypingFormat192VolDiscount(qty,txtbxpartno){
	if(qty <= 7){		
		currentVolumeDiscount = 0;						
	} else if(qty >= 8 && qty <= 12){ 
		currentVolumeDiscount = 10;				
	} else if(qty >= 13 && qty <= 19){ 
		currentVolumeDiscount = 20;				
	}  else if(qty >= 20 && qty <= 30){ 
		currentVolumeDiscount = 30;				
	} else if(qty >= 31 && qty <= 44){ 
		currentVolumeDiscount = 40;			
	} else if(qty >= 45 && qty <= 62 ){ 
		currentVolumeDiscount = 50;				
	} else if(qty >= 63 ){ 
		currentVolumeDiscount = 55;				
	}
	$("#"+txtbxpartno).html(currentVolumeDiscount);
	return currentVolumeDiscount;
}

function GenoTypingFormat256VolDiscount(qty,txtbxpartno){
	if(qty <= 9){		
		currentVolumeDiscount = 0;						
	} else if(qty >= 10 && qty <= 16){ 
		currentVolumeDiscount = 10;				
	} else if(qty >= 17 && qty <= 26){ 
		currentVolumeDiscount = 20;				
	} else if(qty >= 27 && qty <= 39){ 
		currentVolumeDiscount = 30;				
	} else if(qty >= 40 && qty <= 59){ 
		currentVolumeDiscount = 40;				
	} else if(qty >= 60 && qty <= 83 ){ 
		currentVolumeDiscount = 50;				
	} else if(qty >= 84 ){ 
		currentVolumeDiscount = 55;				
	}
	$("#"+txtbxpartno).html(currentVolumeDiscount);
	return currentVolumeDiscount;
}

function GeneExpressionFormat18VolDiscount(qty,txtbxpartno){ 
	if(qty == 1 ){		
		currentVolumeDiscount = 0;			
	} else if(qty == 2 ){ 
		currentVolumeDiscount = 5;
	} else if(qty == 3 ){ 
		currentVolumeDiscount = 10;		
	}  else if(qty == 4 ){ 
		currentVolumeDiscount = 15;	
	} else if(qty >= 5 && qty <= 10){ 
		currentVolumeDiscount = 20;	
	} else if(qty >= 11 ){ 
		currentVolumeDiscount = 25;		
	}
	$("#"+txtbxpartno).html(currentVolumeDiscount);
	return currentVolumeDiscount;
}

function GeneExpressionFormat112CustVolDiscount(qty,txtbxpartno){
	if(qty == 1 ||qty == 2){		
		currentVolumeDiscount = 0;						
	} else if(qty == 3 ){ 
		currentVolumeDiscount = 5;				
	} else if(qty == 4 ){ 
		currentVolumeDiscount = 10;				
	}  else if(qty == 5 ){ 
		currentVolumeDiscount = 15;				
	} else if(qty >= 6 && qty <= 10){ 
		currentVolumeDiscount = 20;				
	} else if(qty >= 11 ){ 
		currentVolumeDiscount = 25;				
	}
	$("#"+txtbxpartno).html(currentVolumeDiscount);
	return currentVolumeDiscount;
}

function GeneExpressionFormat112InventVolDiscount(qty,txtbxpartno){
	if(qty == 1 ){		
		currentVolumeDiscount = 0;					
	} else if(qty == 2 ){ 
		currentVolumeDiscount = 5;				
	} else if(qty == 3 ){ 
		currentVolumeDiscount = 10;				
	}  else if(qty == 4 ){ 
		currentVolumeDiscount = 15;				
	} else if(qty >= 5 && qty <= 10){ 
		currentVolumeDiscount = 20;				
	} else if(qty >= 11 ){ 
		currentVolumeDiscount = 25;			
	}
	$("#"+txtbxpartno).html(currentVolumeDiscount);
	return currentVolumeDiscount;
}

function GeneExpressionFormat168CustVolDiscount(qty,txtbxpartno){
	if(qty <= 3){		
		currentVolumeDiscount = 0;					
	} else if(qty == 4 ){ 
		currentVolumeDiscount = 5;				
	} else if(qty == 5 ){ 
		currentVolumeDiscount = 10;				
	}  else if(qty == 6 ){ 
		currentVolumeDiscount = 15;				
	} else if(qty >= 7 && qty <= 10){ 
		currentVolumeDiscount = 20;				
	} else if(qty >= 11 ){ 
		currentVolumeDiscount = 25;				
	}
	$("#"+txtbxpartno).html(currentVolumeDiscount);
	return currentVolumeDiscount;
}

function GeneExpressionFormat224CustVolDiscount(qty,txtbxpartno){
	if(qty <= 4){		
		currentVolumeDiscount = 0;						
	} else if(qty == 5 ){ 
		currentVolumeDiscount = 5;				
	} else if(qty == 6 ){ 
		currentVolumeDiscount = 10;				
	}  else if(qty == 7 ){ 
		currentVolumeDiscount = 15;				
	} else if(qty >= 8 && qty <= 10){ 
		currentVolumeDiscount = 20;				
	} else if(qty >= 11 ){ 
		currentVolumeDiscount = 25;				
	}
	$("#"+txtbxpartno).html(currentVolumeDiscount);
	return currentVolumeDiscount;
}
function getOpenArrayDiscoutValue(type, qty,txtbxpartno, isCPS){
	var seldisCountObj;// OpenArrayDisVal.findRecord(type, txtbxpartno);
	var selectedRegion = '';
	if( region == "EMEA" || region == "emea"){
		selectedRegion = "EMEA";
	} else {
		selectedRegion = "ALL";
	}
	
	OpenArrayDisVal.each(function (e) {
	   if( e.get(type) == txtbxpartno && e.get("region") == selectedRegion ){
		   seldisCountObj = e;
		}

	});
	 
	
	var bReturn = false;
	if( seldisCountObj == null){
		updateExperimentInfo("cpsDiscountValue", 0);
		bReturn = false;
	}else{
		updateExperimentInfo("cpsDiscountValue", 0);
		var discountObj = seldisCountObj.discounts();
		discountObj.each(function (e) {
			var qtyCheck = (e.get("qty")).split("-");
			if( qtyCheck.length == 2 ){
				if( qty >= parseInt(qtyCheck[0]) && qty <= parseInt(qtyCheck[1]) ){
					if( !isCPS ){						
						updateExperimentInfo("detailsDiscountValue", e.get("discval"));
						$("#"+txtbxpartno).html(e.get("discval"));						
					}else if( isCPS ){
						updateExperimentInfo("cpsDiscountValue", e.get("discval"));
					}
					bReturn = true;
					//return e.get("discval");
				}
			}else{
				if( qty >= parseInt(qtyCheck[0]) ){
					if( !isCPS ){						
						updateExperimentInfo("detailsDiscountValue", e.get("discval"));
						$("#"+txtbxpartno).html(e.get("discval"));
					}else if( isCPS ){
						updateExperimentInfo("cpsDiscountValue", e.get("discval"));
					}	
					//return e.get("discval");
					bReturn = true;
				}			
			}
		});		
	}
	return bReturn;
}
