/* Author: Flavia Nascimento   Date: March 06, 2002   Developed for: Photo Features & Icruz Design*/// constants... price list... to facilitate the price list update...//artwork	// 4x5 format B&W Neg. or Ortho & Colour Negts bw_regSize1 = 21.60  bw_regSize2to10 = 17.30bw_regSize11to20= 16.80bw_regSize21to50= 16.30bw_overSize1 = 35.05bw_overSize2to10 = 28.05bw_overSize11to20 = 27.55bw_overSize21to50 = 27.05	// 4x5 format Col. Transparencyct_regSize1 = 37.80ct_regSize2to10 = 30.25ct_regSize11to20 = 29.75ct_regSize21to50 = 29.25ct_overSize1 = 48.10ct_overSize2to10 = 38.50ct_overSize11to20 = 38.00ct_overSize21to50 = 37.00	// 35mm format B&W Neg. or Ortho & Colour Negts bw_35_regSize1 = 9.95bw_35_regSize2to10 = 7.50bw_35_regSize11to20 = 7.00bw_35_regSize21to50 = 6.75bw_35_overSize1 = 0bw_35_overSize2to10 = 0bw_35_overSize11to20 = 0bw_35_overSize20to50 = 0	// 35mm format Col. Transparencyct_35_regSize1 = 15.00ct_35_regSize2to10 = 12.00ct_35_regSize11to20 = 10.50ct_35_regSize20to50 = 9.95ct_35_overSize1 = 30.00ct_35_overSize2to10 = 25.00ct_35_overSize11to20 = 24.50ct_35_overSize20to50 = 24.00//------------------------------------------// variables declaration to hold the totals ---------------------------	// 4x5 formattotal1= 0 // B&W neg. reg sizetotal2= 0 // B&W neg. over sizetotal3= 0 // Col. neg. reg sizetotal4= 0 // Col. neg. over sizetotal5= 0 // Col. transp. reg sizetotal6= 0 // Col. transp over size	//35 mm formattotal7= 0 // B&W neg. reg sizetotal8= 0 // Col. neg. reg sizetotal9= // Col. transp. reg sizetotal10= 0 // Col. transp over sizetheGrandTotal= 0// -------------------- FUNCTIONS -----------------------------function clearVariables(){  // to empity the variables// it is called on reset and on calculatetotal1= 0total2= 0total3= 0total4= 0total5= 0total6= 0total7= 0total8= 0total9= 0total10= 0theGrandTotal= 0}// end func ---------------------------------------function formatCurrency(num) {num = num.toString().replace(/\$|\,/g,'');if(isNaN(num)) num = "0";cents = Math.floor((num*100+0.5)%100);num = Math.floor((num*100+0.5)/100).toString();if(cents < 10) cents = "0" + cents;for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));return ("$" + num + "." + cents);}// end function ---------------------------// ------------------------------------ Is it A positive integer?function isInt(elm, size) {    if (elm.value >= 0 && elm.value <51 && elm.value !=""){    	return true    } else if (elm.value > 50){    	alert("For this amount, please contact us at (613) 729-9076, for a volume discount.")			elm.value = 0			elm.focus()		return false	}else{    	elm.focus();    	alert ("Please enter a numeric value for the quantity of " + size + " to be processed")    	elm.value = 0;    	elm.select();    	return false    }   } // end func ----------------------------------function validateQuant(total){ // prompt the user a message if all quantities is Zero 	if (total =="0" ){		alert("Please enter the number of negatives to be processed")		}else{}		}// end functionfunction getPrice(Q, p1,p2,p3,p4){  // // this is the basic formula// the conditional stmt is because the price depends on the quantityvar price = 0;		if (Q >= 0 && Q<2){ 			price = (p1*Q);		}else if (Q > 1 && Q < 11){			price = (p2*Q);		}else if (Q > 10 && Q < 21){			price = (p3*Q);		}else if (Q > 20 && Q < 51){			price = (p4*Q);		//}else if (Q > 50){			price = 0;			//alert("For this amount, please contact us at (613) 729-9076, for a volume discount.")			//Q.value = 0		}		return price						} // end func ------------------------------------function getPrice1(){ 	total1 = getPrice(eval(document.frmCopyWork.txtQuant1.value), bw_regSize1, bw_regSize2to10, 	bw_regSize11to20, bw_regSize21to50);	document.frmCopyWork.txtTotal1.value = formatCurrency(total1)}function getPrice2(){ 	total2 = getPrice(eval(document.frmCopyWork.txtQuant2.value), bw_overSize1, bw_overSize2to10, 	bw_overSize11to20, bw_overSize21to50);	document.frmCopyWork.txtTotal2.value = formatCurrency(total2)}function getPrice3(){ 	total3 = getPrice(eval(document.frmCopyWork.txtQuant3.value), bw_regSize1, bw_regSize2to10, 	bw_regSize11to20, bw_regSize21to50);	document.frmCopyWork.txtTotal3.value = formatCurrency(total3)}function getPrice4(){ 	total4 = getPrice(eval(document.frmCopyWork.txtQuant4.value), bw_overSize1, bw_overSize2to10, 	bw_overSize11to20, bw_overSize21to50);	document.frmCopyWork.txtTotal4.value = formatCurrency(total4)}function getPrice5(){ 	total5 = getPrice(eval(document.frmCopyWork.txtQuant5.value), ct_regSize1, ct_regSize2to10,	ct_regSize11to20, ct_regSize21to50);	document.frmCopyWork.txtTotal5.value = formatCurrency(total5)}function getPrice6(){ 	total6 = getPrice(eval(document.frmCopyWork.txtQuant6.value), ct_overSize1, ct_overSize2to10,	ct_overSize11to20, ct_overSize21to50);	document.frmCopyWork.txtTotal6.value = formatCurrency(total6)}function getPrice7(){ 	total7 = getPrice(eval(document.frmCopyWork.txtQuant7.value), bw_35_regSize1, bw_35_regSize2to10,	bw_35_regSize11to20, bw_35_regSize21to50);	document.frmCopyWork.txtTotal7.value = formatCurrency(total7)}function getPrice8(){ 	total8 = getPrice(eval(document.frmCopyWork.txtQuant8.value), bw_35_regSize1, bw_35_regSize2to10,	bw_35_regSize11to20, bw_35_regSize21to50);	document.frmCopyWork.txtTotal8.value = formatCurrency(total8)}function getPrice9(){ 	total9 = getPrice(eval(document.frmCopyWork.txtQuant9.value), ct_35_regSize1, ct_35_regSize2to10,	ct_35_regSize11to20, ct_35_regSize20to50);	document.frmCopyWork.txtTotal9.value = formatCurrency(total9)}function getPrice10(){ 	total10 = getPrice(eval(document.frmCopyWork.txtQuant10.value), ct_35_overSize1, ct_35_overSize2to10,	ct_35_overSize11to20, ct_35_overSize20to50);	document.frmCopyWork.txtTotal10.value = formatCurrency(total10)}function getTheGrandTotal(){ // adds up all  totalstheGrandTotal = total1 + total2 + total3 + total4 + total5 + total6 + total7 + total8+ total9 + total10;document.frmCopyWork.txtGrandTotal.value = formatCurrency(theGrandTotal);document.frmCopyWork.txtGrandTotal2d.value = formatCurrency(theGrandTotal*1.50);document.frmCopyWork.txtGrandTotal1d.value = formatCurrency(theGrandTotal*2);}// end func ---------------------------------------------------function getTotals(){ // call the functions to get each total// it is called by the "calculate" Botton// validates the quantity entryclearVariables() // clear old valuesif (isInt(document.frmCopyWork.txtQuant1, "B&W Negative or Ortho Size Up to 16x20")==false|| isInt(document.frmCopyWork.txtQuant2, "B&W Negative or Ortho & Colour Negatives Size 16x20+ ")==false|| isInt(document.frmCopyWork.txtQuant3, "Colour Negatives Size Up to 16x20")==false|| isInt(document.frmCopyWork.txtQuant4, "Colour Negatives Size 16x20+")==false|| isInt(document.frmCopyWork.txtQuant5, "Col. Transparency Size Up to 16x20")==false|| isInt(document.frmCopyWork.txtQuant6, "Col. Transparency Size 16x20 +")==false|| isInt(document.frmCopyWork.txtQuant7, "B&W Negative or Ortho Up to Size 16x20 ")== false|| isInt(document.frmCopyWork.txtQuant8, "Colour Negatives Up to Size 16x20 ") == false|| isInt(document.frmCopyWork.txtQuant9, "Colour Slides Up to Size 16x20 ")==false|| isInt(document.frmCopyWork.txtQuant10, "Colour Slides Size 16x20 + ")==false){return false}else{getPrice1(); getPrice2(); getPrice3(); getPrice4(); getPrice5();getPrice6();getPrice7(); getPrice8(); getPrice9(); getPrice10(); getTheGrandTotal();validateQuant(theGrandTotal);}// end if}// end func -----------------------------// ----------------------------------------------------------------------------