
function getCostPerDay(weight) {

	//document.getElementById('testtexthere').innerHTML = weight;
   
   if(weight=='' || weight == null) { return 0; }
   
   var perday = getPerDayCosts();  
   return perday[getCostPerDayCategory(weight)];
}  

 ///
 /// Functions for Existing Customers
 ///
 
function presentdog(animal) {

   // make sure that the cells that make up the doggy information can be seen... or not.
   // The cells are:
   //  - existing_dogweight_cell
   //  - existing_playtimes_cell
   //  - existing_bathdips_cell
    
   var animalnumber = (animal-1)*2;
   
   var cells = new Array(6);
   cells[0] = 'existing_dogweight_cell1a';
   cells[1] = 'existing_dogweight_cell1b';
   cells[2] = 'existing_dogweight_cell2a';
   cells[3] = 'existing_dogweight_cell2b';
   cells[4] = 'existing_dogweight_cell3a';
   cells[5] = 'existing_dogweight_cell3b';
   cells[6] = 'existing_dogweight_cell4a';
   cells[7] = 'existing_dogweight_cell4b';
   cells[8] = 'existing_dogweight_cell5a';
   cells[9] = 'existing_dogweight_cell5b';
   cells[10] = 'existing_dogweight_cell6a';
   cells[11] = 'existing_dogweight_cell6b';               
   
   i = 0;
   if(getIsDog(animal) && getBoardedBefore()) {
      document.getElementById(cells[animalnumber++]).style.display = '';
      document.getElementById(cells[animalnumber]).style.display = '';
   }
   else {    
      document.getElementById(cells[animalnumber++]).style.display = 'none';
      document.getElementById(cells[animalnumber]).style.display = 'none';
   }
}

function newpresentdog(animal) {

   // make sure that the cells that make up the doggy information can be seen... or not.
   // The cells are:
   //  - existing_dogweight_cell
   //  - existing_playtimes_cell
   //  - existing_bathdips_cell
    
   var animalnumber = (animal-1)*2;
   
   var cells = new Array(6);
   cells[0] = 'weight_animal';
   cells[1] = 'weight1';
   cells[2] = 'weight_animal1';
   cells[3] = 'weight2';
   cells[4] = 'weight_animal2';
   cells[5] = 'weight3';
   cells[6] = 'weight_animal3';
   cells[7] = 'weight4';
   cells[8] = 'weight_animal4';
   cells[9] = 'weight5';
   
   var shots = new Array();
   
   shots[0] = new Array();
   shots[0][1] = 'shot2animal1';
   shots[0][2] = 'shot3animal1';

   shots[2] = new Array();
   shots[2][1] = 'shot2animal2';
   shots[2][2] = 'shot3animal2';   
   
   shots[4] = new Array();
   shots[4][1] = 'shot2animal3';
   shots[4][2] = 'shot3animal3';

   shots[6] = new Array();
   shots[6][1] = 'shot2animal4';
   shots[6][2] = 'shot3animal4';

   shots[8] = new Array();
   shots[8][1] = 'shot2animal4';
   shots[8][2] = 'shot3animal4';   
   
   i = 0;
   if(getNewIsDog(animal) && !getBoardedBefore()) {
      document.getElementById(shots[animalnumber][1]).innerHTML = 'Bordetella (Expires)';
	  document.getElementById(shots[animalnumber][2]).innerHTML = 'DHLP (Expires)';   
   
      document.getElementById(cells[animalnumber++]).style.display = '';
      document.getElementById(cells[animalnumber]).style.display = '';
   }
   else {
	  document.getElementById(shots[animalnumber][1]).innerHTML = 'FeLuek (Expires)';
	  document.getElementById(shots[animalnumber][2]).innerHTML = 'FVRCP (Expires)';
	  
      document.getElementById(cells[animalnumber++]).style.display = 'none';
      document.getElementById(cells[animalnumber]).style.display = 'none';
	  
		
	  
   }
}

function getNewDogWeight(index) {
     
   weights = getAllNewWeights(); 
   weight = weights[index];

   if(isNumeric(weight) && weight != 0) { 
     return weight;
   } else {
      return 0;
   }
} 

function getCostForNewAnimal(animal) {
   if(document.getElementById('pets').value > (animal-1)) { 
      if(getNewIsDog(animal)) {
         return getCostPerDay(getNewDogWeight(animal)).toFixed(2);
      }
      else {
         return getCatPerDayCost().toFixed(2);
      }
   }
   else {
      return 0;   
   }
}
 
 function getTotalCostPerDayNew() {
       var numpets = getNumPets();
       var oform = document.orderform;
        
      var dayscost1 = 0; if(numpets >= 1) { dayscost1 = getCostForNewAnimal(1); }
      var dayscost2 = 0; if(numpets >= 2) { dayscost2 = getCostForNewAnimal(2); }
      var dayscost3 = 0; if(numpets >= 3) { dayscost3 = getCostForNewAnimal(3); } 
      var dayscost4 = 0; if(numpets >= 4) { dayscost4 = getCostForNewAnimal(4); }
      var dayscost5 = 0; if(numpets >= 5) { dayscost5 = getCostForNewAnimal(5); }  
         
      return dayscost1*1 + dayscost2*1 + dayscost3*1 + dayscost4*1 + dayscost5*1 - getNewBoardDogsTogetherDiscount() - getNewBoardCatsTogetherDiscount();
 }
 
function calculateNotBoardedBefore() {
    
   if(!checkValidNewFormFields()) {
      document.getElementById('estimatedtotal').innerHTML = 'Please complete all fields.';
   } 
   else {
      
      var bathsdipscost = 1*getCostOfNewBathdipsByValue(1);
      bathsdipscost += 1*getCostOfNewBathdipsByValue(2);
      bathsdipscost += 1*getCostOfNewBathdipsByValue(3);
      bathsdipscost += 1*getCostOfNewBathdipsByValue(4);
      bathsdipscost += 1*getCostOfNewBathdipsByValue(5);       
      
      totalcost = getCostOfNewPlaytimes()*1 + bathsdipscost + getTotalCostPerDayNew()*(calculateNumberOfDays()*1 + getChargeForExtraDays()*1);
                         
      updateTotalCost(totalcost.toFixed(2));
   }
}
 
function getChargeForExtraDays() {
   // if the user has selected a drop-off time that is in the afternoon, then we need to add an extra day
   // to the charge.
     
   if(getPickUpTime() == '3:30pm-6:00pm M-F' || getPickUpTime() == '4:00pm-6:00pm Sunday') {
      return 1;
   }
   else {
      return 0;
   }   
}

/**
   The Daddy function
**/
function calculatecost() {   
   
   document.getElementById('estimatedtotaltext').style.display = '';
   
   if(getBoardedBefore()==true) {
      getCostOfExistingPets();
   }
   else {
      calculateNotBoardedBefore();
   }
      updateCostPerDay();
      updatePlaytimesCost();
      updateBathDipsCost();    
} 