/* Author: Flavia Nascimento
   Date: March 06, 2002
   Developed for: Photo Features & Icruz Design
*/




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 ---------------------------




function verifyIfQuantIsNotZero(qt,chkBox){

if (qt.value == "0"){
alert ("Please enter a quantity");
chkBox.checked = false 
qt.focus();
return false;
}else{

return true
}
}


// ------------------------------------ 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 slides " + size + " to be duplicated")
    	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 slides to be duplicated")
		}else{}
		
}// end function



function minimumValue(grandTo){
	if (grandTo < 25.00){
	alert ("The minimum Order for this services is $ 25.00");
	
	}else{
	// procede	
	}
}// end func


//--------------SLIDE DUPLICATION -------------------------------

/* Author: Flavia Nascimento
   Date: February 08, 2002
   Developed for: Photo Features & Icruz Design
*/

// constants... price list... to facilitate the price list update...
 // price list for slide duplication 35 mm from 35mm Format
slide_35= 9.95
slide_35_6to10 = 8.95
slide_35_11to20 = 8.25
slide_35_21to50 = 7.95

 // price list for slide duplication 35 mm from 120 & 4x5 Format

from120= 17.50
from120_6to10= 12.50
from120_11to20= 11.50
from120_21to50= 11.00

slideSset = 2.20
	

//------------------------------------------
// variables declaration to hold the totals ---------------------------


theGrandTotal_slide= 0
total1_slide=0
total2_slide=0



// -------------------- FUNCTIONS -----------------------------

function clearVariables_slide(){  // to empity the variables
// it is called on reset and on calculate



theGrandTotal_slide= 0
total1_slide=0
total2_slide=0


}// end func ---------------------------------------

// checks weather the checkBox is selected or not. If it is gets the value 
	
function getCheckBoxValue(checkBox, value){
	with (checkBox.form) {

	if (checkBox.checked == true)
	return eval(value);
	else
	return 0;
		}
	}


function getPrice_slide(Q, p1,p2,p3,p4,sset){  
// gets the total of B&W negative
// the conditional stmt is because the price depends on the quantity

		if (Q >=0 && Q<6){ 
			return ((p1 + sset) * Q);
		}else if (Q > 5 && Q < 11){
			return ((p2 + sset) * Q);
		}else if (Q > 10 && Q < 21){
			return ((p3 + sset) * Q);
		}else if (Q > 20 && Q < 51){
			return ((p4 + sset)* Q);
		}else{
		  return 0;
		}// end if	
			

} // end func ------------------------------------

function getPrice1_slide() {

	total1_slide = getPrice_slide(document.frmSlideDuplication.txtQuant1.value, slide_35, slide_35_6to10,
	slide_35_11to20, slide_35_21to50, getCheckBoxValue(document.frmSlideDuplication.chkSset1, slideSset));

	document.frmSlideDuplication.txtTotal1.value = formatCurrency(total1_slide);

}// end func


function getPrice2_slide() {

	total2_slide = getPrice_slide(document.frmSlideDuplication.txtQuant2.value, from120, 
	from120_6to10, from120_11to20, from120_21to50, getCheckBoxValue(document.frmSlideDuplication.chkSset2, slideSset));


	document.frmSlideDuplication.txtTotal2.value = formatCurrency(total2_slide);

}// end func

function gettheGrandTotal_slide(){ // adds up all  totals

theGrandTotal_slide = total1_slide + total2_slide;
document.frmSlideDuplication.txtGrandTotal.value = formatCurrency(theGrandTotal_slide);
document.frmSlideDuplication.txtGrandTotal3d_slide.value = formatCurrency(theGrandTotal_slide*1.50);
document.frmSlideDuplication.txtGrandTotal1d_slide.value = formatCurrency(theGrandTotal_slide*2);

}// end func ---------------------------------------------------


function getTotals_slide(){ // call the functions to get each total
// it is called by the "calculate" Botton
// validates the quantity entry

clearVariables_slide() // clear old values

if(isInt(document.frmSlideDuplication.txtQuant1, "35mm ")==false
|| 
isInt(document.frmSlideDuplication.txtQuant2, "120 or 4x5 ")==false){

return false
}else{


     
getPrice1_slide(); 

getPrice2_slide();   
gettheGrandTotal_slide();
//validateQuant(theGrandTotal_slide);
minimumValue(theGrandTotal_slide);


}//end fi
}// end func -----------------------------

//------------------------------------------------------------------------------


