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


// photography price list

// ----------camara charges ----------------//
// 35mm format w/ portable on - camara strobe

hour1_35 = 137.50  // first hour
hour2_35 = 247.00 // second hour
halfDay_35 = 365.00 // half day
fullDay_35 = 635.00 // full day

// 35mm or 120 format w/ multple head studio flash on location

hour1_35or120 = 0  // first hour -> not available
hour2_35or120 = 265.00 // second hour
halfDay_35or120 = 430.00 // half day
fullDay_35or120 = 770.00 // full day

// 4x5 format in studio or in location

hour1_4x5 = 0  // first hour not available
hour2_4x5 = 350.00 // second hour
halfDay_4x5 = 550.00 // half day
fullDay_4x5 = 900.00 // full day

// ------- film processing ---------------
// black & white

bw35 = 32.40
bw120= 32.40
bw220= 64.80
bw4x5= 10.30
bwPolaroid = 4.50

// Negative colour

col35 = 33.40
col120= 33.40
col220= 66.80
col4x5= 11.30
colPolaroid = 5.50


// Negative Tansparency

tran35 = 36.00
tran120= 36.30
tran220= 72.60
tran4x5= 15.00



cooFee = 80.00 // coordination fee
km = 0.42
perhour = 27.50

bigTotal=0 // variable to hold all total for film process


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 clearOtherCity(city){

city.value = "";


}// end function




// ------------------------------------ Is it A positive integer?
function isInt(elm, size) {

    if (elm.value >= 0 && elm.value <10000 && elm.value !=""){
    	return true
    
	}else{

    	elm.focus();
    	alert ("Please enter a numeric value for " + size)
    	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 function

function getCameraCharges(camera, duration){

var camType = 0
var dur = 0
var uPrice = 0
	
	for (i=0; i<camera.length; i++){
		if (camera.options[i].selected==true){
		camType= camera.options[i].value
		}// end if
			
			
	}// end loop
	
	
	for (i=0; i<duration.length; i++){
		if (duration.options[i].selected==true){
		dur= duration.options[i].value
		}// end if
			
			
	}// end loop


			if (camType=="a" && dur=="a"){
			uPrice = hour1_35;}
			else if (camType=="a" && dur=="b"){
			uPrice = hour2_35;}
			else if (camType=="a" && dur=="c"){
			uPrice = halfDay_35;}
			else if (camType=="a" && dur=="d"){
			uPrice = fullDay_35;}
			else if (camType=="b" && dur=="a"){
			alert ("Minimum two hours, for this service");
			
					
			duration.options[1].selected = true;
			duration.focus();
			uPrice = hour2_35or120;}
			
			

			else if (camType=="b" && dur=="b"){
			uPrice = hour2_35or120;}
			else if (camType=="b" && dur=="c"){
			uPrice = halfDay_35or120;}
			else if (camType=="b" && dur=="d"){
			uPrice = fullDay_35or120;}
			else if (camType=="c" && dur=="a"){
			alert ("Minimum two hours, for this service");

			duration.options[1].selected = true;
			duration.focus();
			uPrice =  hour2_4x5;}
			

			else if (camType=="c" && dur=="b"){
			uPrice = hour2_4x5;}
			else if (camType=="c" && dur=="c"){
			uPrice = halfDay_4x5;}
			else if (camType=="c" && dur=="d"){
			uPrice = fullDay_4x5;}
	
		return uPrice;

}// end func


function getPriceProcessByFilm(qt, value){
	
//	var qt=0 // variable to hold the quantity

	
		return (qt*value)
	
}//end function ---------------------

function getProcess(){
bigTotal=0

if (isInt(document.frmPhotography.BW_Neg_35mm, "B&W/Negative 35mm")==false ||
isInt(document.frmPhotography.BW_Neg_120, "B&W/Negative 120")==false ||
isInt(document.frmPhotography.BW_Neg_220, "B&W/Negative 220")==false ||
isInt(document.frmPhotography.BW_Neg_4x5, "B&W/Negative 4x5")==false ||
isInt(document.frmPhotography.Col_Neg_35mm, "Colour/Negative 35mm")==false ||
isInt(document.frmPhotography.Col_Neg_120, "Colour/Negative 120") ==false ||
isInt(document.frmPhotography.Col_Neg_220, "Colour/Negative 220") ==false ||
isInt(document.frmPhotography.Col_Neg_4x5, "Colour/Negative 4x5") ==false ||
isInt(document.frmPhotography.Col_Slide_35mm, "Colour Slide 35mm")==false ||
isInt(document.frmPhotography.Col_Slide_120, "Colour Slide 120")==false ||
isInt(document.frmPhotography.Col_Slide_220, "Colour Slide 220") ==false ||
isInt(document.frmPhotography.Col_Slide_4x5, "Colour Slide 4x5")==false ){

return false

}else{

bigTotal= (
getPriceProcessByFilm(document.frmPhotography.BW_Neg_35mm.value, bw35) + 
getPriceProcessByFilm(document.frmPhotography.BW_Neg_120.value, bw120) + 
getPriceProcessByFilm(document.frmPhotography.BW_Neg_220.value, bw220) + 
getPriceProcessByFilm(document.frmPhotography.BW_Neg_4x5.value, bw4x5) + 
getPriceProcessByFilm(document.frmPhotography.Col_Neg_35mm.value, col35) + 
getPriceProcessByFilm(document.frmPhotography.Col_Neg_120.value, col120) + 
getPriceProcessByFilm(document.frmPhotography.Col_Neg_220.value, col220) + 
getPriceProcessByFilm(document.frmPhotography.Col_Neg_4x5.value, col4x5) + 
getPriceProcessByFilm(document.frmPhotography.Col_Slide_35mm.value, tran35) + 
getPriceProcessByFilm(document.frmPhotography.Col_Slide_120.value, tran120) + 
getPriceProcessByFilm(document.frmPhotography.Col_Slide_220.value, tran220) + 
getPriceProcessByFilm(document.frmPhotography.Col_Slide_4x5.value, tran4x5)
);

return bigTotal;
}// end if

}//end function -----------------


function getPolaroidPrice(qt){

	
	return (qt * colPolaroid);


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


function getTravellingCost(kms, horas){

return ((kms * km) + (horas * perhour));


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


function getCoFee(city){
var ct = "";
for (i=0; i<city.length; i++){
		if (city.options[i].selected==true){
		ct= city.options[i].value
		}// end if
			
			
	}// end loop


			if (ct != "	Ottawa/ON	"){

			return 80;
			}else{
			return 0;
			}// end if

}// end function

function getTotals_photo(){
var grandTotal_photo = 0

if (isInt(document.frmPhotography.txtKm, "Kilometers")==false ||
isInt(document.frmPhotography.txtTravelHours, "hours")==false
||getProcess()==false){

return false

}else{

grandTotal_photo = getCameraCharges(document.frmPhotography.ddmCamera, document.frmPhotography.ddmDuration)
+ getProcess()
+ getPolaroidPrice(document.frmPhotography.txtPolaroids.value)
+ getTravellingCost(document.frmPhotography.txtKm.value, document.frmPhotography.txtTravelHours.value) 
+ getCoFee(document.frmPhotography.ddmCity);


document.frmPhotography.txtTotal.value = formatCurrency(grandTotal_photo)
}// end if

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