
function validate(theForm) {
 if (document.theForm.mail_customer.checked == true || document.theForm.contact_customer.checked == true) {
   if (document.theForm.name.value == "") {
      alert('Oops! You clicked the Submit button but you did not enter your name!');
      document.theForm.name.select();
      document.theForm.name.focus();
      return (false);
   }
   if (document.theForm.mail_customer.value != "") {
      if (document.theForm.email.value == "") {
         alert('Oops! You requested that we email you this quote but you did not enter your email address!');
         document.theForm.email.select();
         document.theForm.email.focus();
         return (false);
      }
      if ((document.theForm.email.value.indexOf('@',0)==-1) || (document.theForm.email.value.indexOf('.',0)==-1)) {
         alert("\nINVALID E-MAIL ADDRESS! The syntax is incorrect. Your email address should look something like yourname\@host.com.");
         document.theForm.email.select();
         document.theForm.email.focus();
         return (false);
      }
   }
 }
 if (document.theForm.total_design_cost.value == "$0.00" && document.theForm.total_monthly_cost.value == "$0.00") {
      alert('Oops! You haven\'t included any features in your estimate so we have nothing to calculate for you!');
      return (false);
 }
 return (true);
}

   function formatPrice(new_price) {
      new_price = Math.round(new_price*Math.pow(10,2))/Math.pow(10,2);
      price = new_price + "";
      decimalstart = price.indexOf(".");
      if (decimalstart > 0) {
        price = price.substring(0,decimalstart+3);
      }
      if (decimalstart < 1) {
        price = price + ".00";
      }
      if (price.substring(decimalstart+1).length < 2) {
        price = price + "0";
      }
      return price;
   }


function getFees(theForm) {

   total_design = 0;
   total_monthly = 0;

   if (document.theForm.homepage[0].checked) {
       if (document.theForm.shomepage_type[0].checked) {
           homepage_fee = 395.00;
       } else if (document.theForm.shomepage_type[1].checked) {
           homepage_fee = 450.00;
       }
   } else if (document.theForm.homepage[1].checked) {
       if (document.theForm.nhomepage_type[0].checked) {
           homepage_fee = 635.00;
       } else if (document.theForm.nhomepage_type[1].checked) {
           homepage_fee = 690.00;
       }
   } else {
     homepage_fee = 0.00;
   }

   if (document.theForm.products.checked) {
       if (document.theForm.products_type[0].checked) {
           products_fee = 65.00;
       } else {
           products_fee = 110.00;
       }
   } else {
     products_fee = 0.00;
   }

   if (document.theForm.aboutus.checked) {
       if (document.theForm.aboutus_type[0].checked) {
           aboutus_fee = 65.00;
       } else {
           aboutus_fee = 110.00;
       }
   } else {
     aboutus_fee = 0.00;
   }

   if (document.theForm.contact.checked) {
       if (document.theForm.contact_type[0].checked) {
           contact_fee = 65.00;
       } else {
           contact_fee = 110.00;
       }
   } else {
     contact_fee = 0.00;
   }

   if (document.theForm.sitemap.checked) {
       if (document.theForm.sitemap_type[0].checked) {
           sitemap_fee = 65.00;
       } else {
           sitemap_fee = 110.00;
       }
   } else {
     sitemap_fee = 0.00;
   }

   if (document.theForm.privacy.checked) {
       if (document.theForm.privacy_type[0].checked) {
           privacy_fee = 65.00;
       } else {
           privacy_fee = 110.00;
       }
   } else {
     privacy_fee = 0.00;
   }

   if (document.theForm.whatsnew.checked) {
       if (document.theForm.whatsnew_type[0].checked) {
           whatsnew_fee = 65.00;
       } else {
           whatsnew_fee = 110.00;
       }
   } else {
     whatsnew_fee = 0.00;
   }

   if (document.theForm.feature.checked) {
       if (document.theForm.feature_type[0].checked) {
           feature_fee = 65.00;
       } else {
           feature_fee = 110.00;
       }
   } else {
     feature_fee = 0.00;
   }

   if (document.theForm.staff.checked) {
       if (document.theForm.staff_type[0].checked) {
           staff_fee = 65.00;
       } else {
           staff_fee = 110.00;
       }
   } else {
     staff_fee = 0.00;
   }

   if (document.theForm.events.checked) {
       if (document.theForm.events_type[0].checked) {
           events_fee = 65.00;
       } else {
           events_fee = 110.00;
       }
   } else {
     events_fee = 0.00;
   }

   if (!(document.theForm.additional_static.value == "")) {
       additional_static_fee = (document.theForm.additional_static.value * 65.00);
   } else {
       additional_static_fee = 0.00;
   }

   if (!(document.theForm.additional_dynamic.value == "")) {
       additional_dynamic_fee = (document.theForm.additional_dynamic.value * 110.00);
   } else {
       additional_dynamic_fee = 0.00;
   }

   if (document.theForm.email_form.checked) {
       email_form_fee = 95.00;
   } else {
       email_form_fee = 0.00;
   }

   if (document.theForm.address_form.checked) {
       address_form_fee = 125.00;
   } else {
       address_form_fee = 0.00;
   }

   if (document.theForm.bulkmail_form.checked) {
       bulkmail_form_fee = 125.00;
   } else {
       bulkmail_form_fee = 0.00;
   }

   if (document.theForm.search_engine.checked) {
       search_engine_fee = 150.00;
   } else {
       search_engine_fee = 0.00;
   }

   if (document.theForm.ecommerce.checked) {
       if (document.theForm.ecom_type[0].checked) {
           homepage_fee = 0.00;
           ecommerce_fee = 1895.00;
             if (document.theForm.homepage[0].checked) {
                document.theForm.homepage[0].checked = false;
             } else if (document.theForm.homepage[1].checked) {
                document.theForm.homepage[1].checked = false;
             }
       } else if (document.theForm.ecom_type[1].checked) {
           ecommerce_fee = 1895.00;
       } else {
           ecommerce_fee = 0.00;
           alert('Please check "As Standalone Home Page" if this e-commerce shopping cart store will be your home page, or check "In Addition To Home Page" if you will have a separate home page and the store will link from it.');
           document.theForm.ecom_type[0].focus;
       }
   } else {
       ecommerce_fee = 0.00;
   }

   if (document.theForm.affiliate.checked) {
       affiliate_fee = 250.00;
   } else {
       affiliate_fee = 0.00;
   }

   if (document.theForm.error_pages.checked) {
       error_pages_fee = 50.00;
   } else {
       error_pages_fee = 0.00;
   }

   if (document.theForm.links.checked) {
       links_fee = 85.00;
   } else {
       links_fee = 0.00;
   }

   if (document.theForm.classifieds.checked) {
       classifieds_fee = 85.00;
   } else {
       classifieds_fee = 0.00;
   }

   if (document.theForm.forum.checked) {
       forum_fee = 125.00;
   } else {
       forum_fee = 0.00;
   }

   if (document.theForm.guestbook.checked) {
       guestbook_fee = 75.00;
   } else {
       guestbook_fee = 0.00;
   }

   if (document.theForm.members.checked) {
       members_fee = 95.00;
   } else {
       members_fee = 0.00;
   }

   if (document.theForm.fileman.checked) {
       fileman_fee = 45.00;
   } else {
       fileman_fee = 0.00;
   }

   if (document.theForm.se.checked) {
       se_fee = 185.00;
   } else {
       se_fee = 0.00;
   }

   if (document.theForm.ase.checked) {
       ase_fee = 295.00;
   } else {
       ase_fee = 0.00;
   }

   if (document.theForm.domain_transfer.checked) {
       domain_transfer_fee = 25.00;
   } else {
       domain_transfer_fee = 0.00;
   }

   var hostingCt = document.theForm.hosting.length;
   var hostinghecked = 0;
   var hosting_plan = "";
   var hosting_fee = 0;
   var hosting_duration = "";
   var last = "";
   for(i = 0; i < hostingCt; i++) {
     if (document.theForm.hosting[i].checked) {
         hostinghecked++;
         var hostingArr = document.theForm.hosting[i].value.split("|");
         hosting_plan = hostingArr[0];
         hosting_fee = hostingArr[1];
         var planArr = hosting_plan.split(" ");
         if (planArr[0] == 'Dedicated') {
           hosting_duration = planArr[3];
         } else {
           hosting_duration = planArr[2];
         }
         hosting_fee = (hosting_fee * 1);
         if (hosting_duration != "Monthly") {
            hosting_duration = (hosting_duration * 1);
            hosting_fee = (hosting_fee / hosting_duration);
         }
     }
   }
   if (document.theForm.hosting[18].checked) {
       hosting_fee = 0;
   }
   if (hostingCt > 0 && document.theForm.fileman.checked) {
       document.theForm.fileman.checked = false;
       fileman_fee = 0;
   }
//   hosting_fee = formatPrice(hosting_fee);


   if (document.theForm.maintenance[0].checked) {
       maintenance_fee = 90.00;
   } else if (document.theForm.maintenance[1].checked) {
       maintenance_fee = 168.00;
   } else if (document.theForm.maintenance[2].checked) {
       maintenance_fee = 234.00;
   } else if (document.theForm.maintenance[3].checked) {
       maintenance_fee = 25.00;
   } else if (document.theForm.maintenance[4].checked) {
       maintenance_fee = 0.00;
   } else {
       maintenance_fee = 0.00;
   }

   total_design = (homepage_fee + products_fee + aboutus_fee + contact_fee + sitemap_fee + privacy_fee + whatsnew_fee + feature_fee + staff_fee + events_fee + additional_static_fee + additional_dynamic_fee + email_form_fee + address_form_fee + bulkmail_form_fee + search_engine_fee + ecommerce_fee + affiliate_fee + error_pages_fee + links_fee + classifieds_fee + forum_fee + guestbook_fee + members_fee + fileman_fee + se_fee + ase_fee + domain_transfer_fee);

   total_monthly = (hosting_fee + maintenance_fee);

   total_design = total_design + "";
   decimalstart1 = total_design.indexOf(".");

   if (decimalstart1 > 0) {
     total_design = total_design.substring(0,decimalstart1+3);
   }
   if (decimalstart1 < 1) {
     total_design = total_design + ".00";
   }
   if (total_design.substring(decimalstart1+1).length < 2) {
     total_design = total_design + "0";
   } 

   total_monthly = total_monthly + "";
   decimalstart2 = total_monthly.indexOf(".");

   if (decimalstart2 > 0) {
     total_monthly = total_monthly.substring(0,decimalstart2+3);
   }
   if (decimalstart2 < 1) {
     total_monthly = total_monthly + ".00";
   }
   if (total_monthly.substring(decimalstart2+1).length < 2) {
     total_monthly = total_monthly + "0";
   } 
   document.theForm.total_design_cost.value = "\$" + total_design;
   document.theForm.total_monthly_cost.value = "\$" + total_monthly;
   document.theForm.total_design_cost2.value = "\$" + total_design;
   document.theForm.total_monthly_cost2.value = "\$" + total_monthly;
}

