/* Author: Flavia Nascimento   Date: March 17, 2002   Developed for: Photo Features & Icruz Design*/// constants... price list... to facilitate the price list update...//batch scanbs1= 5.50bs2_10= 3.00 // 2 to 10 scansbs11_20 = 2.00 // 11 to 20 scansbs21 = 1.50 // 21+ scans//individual scanis1= 12.50is2_10= 9.50 // 2 to 10 scansis11_20 =7.50// 11 to 20 scansis21 = 5.50 // 21+ scans//high resolution	// 35mmhr35_1= 20.00hr35_2_10= 15.50// 2 to 10 scanshr35__20 = 12.50 // 11 to 20 scanshr35_21 = 9.50 // 21+ scans// 120hr120_1= 27.50hr120_2_10= 25.00// 2 to 10 scanshr120__20 = 22.50 // 11 to 20 scanshr120_21 = 12.50 // 21+ scans// 4x5hr4x5_1= 35.00hr4x5_2_10= 30.00// 2 to 10 scanshr4x5__20 = 25.00 // 11 to 20 scanshr4x5_21 = 22.50 // 21+ scans// transparencieshrTra_1= 45.00hrTra_2_10= 40.00// 2 to 10 scanshrTra__20 = 35.00 // 11 to 20 scanshrTra_21 = 30.00 // 21+ scans	// image delivarydelEmail = 3.50  // by imagedelCD = 10.00 // CDdelCDc=25.00 // CD w/ cover//------------------------------------------// variables declaration to hold the totals ---------------------------	// 4x5 formattotal1= 0 // batch scan 4x6total2= 0 // batch scan 35mm total3= 0 // individual scantotal4= 0 // high resolution from 35mmtotal5= 0 // high resolution from 120total6= 0 // high resolution from 4x5total7= 0 // high resolution from transparencytheGrandTotal= 0// -------------------- FUNCTIONS -----------------------------function clearVariables_scan(){  // to empity the variables// it is called on reset and on calculatetotal1= 0total2= 0total3= 0total4= 0total5= 0total6= 0total7= 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 scanned")    	elm.value = 0;    	elm.select();    	return false    } // end if   } // end func ----------------------------------function validateQuant(total){ // prompt the user a message if all quantities is Zero 	if (total =="0" ){		alert("Please enter the number of files to be scanned")		}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);				}		return price						} // end func ------------------------------------function getPrice1(){ 	total1 = getPrice(eval(document.frmScanning.txtQuant1.value), bs1, bs2_10, bs11_20, bs21);	document.frmScanning.txtTotal1.value = formatCurrency(total1);	}// end func ------------------------------------function getPrice2(){ 	total2 = getPrice(eval(document.frmScanning.txtQuant2.value), bs1, bs2_10, bs11_20, bs21);	document.frmScanning.txtTotal2.value = formatCurrency(total2);	}// end func ------------------------------------function getPrice3(){ 	total3 = getPrice(eval(document.frmScanning.txtQuant3.value), is1,is2_10, is11_20, is21);	document.frmScanning.txtTotal3.value = formatCurrency(total3);	}// end func ------------------------------------function getPrice4(){ 	total4 = getPrice(eval(document.frmScanning.txtQuant4.value), hr35_1,hr35_2_10, hr35__20, hr35_21);	document.frmScanning.txtTotal4.value = formatCurrency(total4);	}// end func ------------------------------------function getPrice5(){ 	total5 = getPrice(eval(document.frmScanning.txtQuant5.value), hr120_1,hr120_2_10, hr120__20, hr120_21);	document.frmScanning.txtTotal5.value = formatCurrency(total5);}// end func ------------------------------------function getPrice6(){ 	total6 = getPrice(eval(document.frmScanning.txtQuant6.value), hr4x5_1,hr4x5_2_10, hr4x5__20, hr4x5_21);	document.frmScanning.txtTotal6.value = formatCurrency(total6);	}// end func ------------------------------------function getPrice7(){ 	total7 = getPrice(eval(document.frmScanning.txtQuant7.value), hrTra_1,hrTra_2_10, hrTra__20, hrTra_21);	document.frmScanning.txtTotal7.value = formatCurrency(total7);	}// end func ------------------------------------function getPrice8(deliver){ var del = ""var delPrice = 0	for (i=0; i<deliver.length; i++){	   if (deliver[i].checked == true){		del = deliver[i].value	}// end if	}// end loop			if (del == "a"){	delPrice = (delEmail * (eval(document.frmScanning.txtQuant1.value) +				eval(document.frmScanning.txtQuant2.value) +				eval(document.frmScanning.txtQuant3.value) +				eval(document.frmScanning.txtQuant4.value) +				eval(document.frmScanning.txtQuant5.value) +				eval(document.frmScanning.txtQuant6.value) +				eval(document.frmScanning.txtQuant7.value) )); 		}else if (del == "b"){	delPrice = delCD;	}else if (del == "c"){	delPrice = delCDc;	}// end if		total8 = delPrice	document.frmScanning.txtTotal8.value = formatCurrency(total8);	}// end func ------------------------------------function getTheGrandTotal(){ // adds up all  totalstheGrandTotal = total1 +   total2 + total3  +  total4 + total5  +  total6 + total7 + total8;document.frmScanning.txtGrandTotal.value = formatCurrency(theGrandTotal);document.frmScanning.txtGrandTotal2d.value = formatCurrency(theGrandTotal*1.50);document.frmScanning.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_scan() // clear old valuesif(isInt(document.frmScanning.txtQuant1, "4 x6 slides")==false|| isInt(document.frmScanning.txtQuant2, "35mm slides")==false|| isInt(document.frmScanning.txtQuant3, "Individual Scans")==false|| isInt(document.frmScanning.txtQuant4, "High Resolution 35mm")==false|| isInt(document.frmScanning.txtQuant5, "High Resolution 120")==false|| isInt(document.frmScanning.txtQuant6, "High Resolution 4x5")==false|| isInt(document.frmScanning.txtQuant7, "High Resolution from Transparencies ")==false){return false}else{getPrice1(); getPrice2(); getPrice3(); getPrice4(); getPrice5();getPrice6();getPrice7(); getPrice8(document.frmScanning.grpDelivery); getTheGrandTotal();validateQuant(theGrandTotal);}//end if}// end func -----------------------------