
function Calculator(myObject)
{
            var theForm = myObject.form;
				var PayTerm = 1;
            var HostingTotal = 0;
				var HostingFee = 0;
				var MirrorServer = 0;
				var MirrorServerUSD = 0;
				var WeeklyBackup = 0;
				var SSLCertificate = 0;
				var ExclusiveIP = 0;
				var SEPromo = 0;
				var ShellAccount = 0;
				var ExtraTraffic = 0;
				var ExtraMail = 0;
				var ExtraSpace = 0;
				var ExtraPromoURLsStep4_USD1 = 0;
				var ExtraSpiderURLsStep5_USD1 = 0;
            	var PromoTotal = 0;
            	var RankCheckTotal = 0;
				var monthlyRankCheck = 0;
				var ExtraRankURLsStep2 = 0;
				var ExtraResultsStep100 = 0;
				var MailFee = 0;
				var WebHostingPlan = theForm.WebHostingPlan.value;
				var Comments = theForm.comments.value;
				var SetupFee = 0;
				var FreePopMail = 0;

				if (WebHostingPlan == "Budget") {
					HostingFee=3
					SetupFee = 0;
					FreePopMail = 999;
				}
				if (WebHostingPlan == "Basic") {
					HostingFee=8;
					SetupFee = 0;
					FreePopMail = 999;
					MirrorServer = 12
				}
				if (WebHostingPlan == "Business") {
					HostingFee=20;
					SetupFee = 0;
					FreePopMail = 1000;
					MirrorServer = 12;
					//theForm.PayMonth[1].checked = true
				}
				if (WebHostingPlan == "Pro") {
					HostingFee=35;
					SetupFee = 0;
					FreePopMail = 1000;
					MirrorServer = 20;
					theForm.ExclusiveIP.checked = true;
				}
				if (WebHostingPlan == "Forward") {
					HostingFee=1;
				}
				if (WebHostingPlan == "Shared") {
					HostingFee=1;
				}
				if (WebHostingPlan == "MailServer") {
					HostingFee=1;
				}
				if (WebHostingPlan == "MailDomain") {
					HostingFee= 0;
					theForm.PayMonth[0].checked=false;
					theForm.PayMonth[1].checked=false;
					theForm.PayMonth[2].checked=true;
					MailFee = 35;
				}
				if (WebHostingPlan == "MailAccount") {
					HostingFee=0;
					MailFee = 26;
				}
				if (Comments == "SocialHost") {
					HostingFee=0;
					theForm.WebHostingPlan.value = "Plan A";
				}


				if( theForm.WeeklyBackup.checked ) {WeeklyBackup = 5;}
				if( theForm.SSLCertificate.checked ) {SSLCertificate = 60;}
				//if( theForm.MirrorServer.checked ) { MirrorServerUSD = MirrorServer;}
				if( theForm.ExclusiveIP.checked && HostingFee < 35) {ExclusiveIP = 5;}
 				if( theForm.ShellAccount.checked ) {ShellAccount = 5;}
 				ExtraTraffic = (2*parseInt( theForm.ExtraTraffic.value)+0);
 				ExtraSpace   = parseInt( theForm.ExtraSpace.value)+0;
 				if (ExtraSpace>0 ){ ExtraSpace = (3*parseInt( (theForm.ExtraSpace.value)));}

 				if( theForm.SESpider.checked==true) {
					SEPromo = 5;
					theForm.SEPromo.checked=false;
					var $Count = WordCount(theForm.ListOfPromoURLs.value);
					if ($Count>20) { ExtraSpiderURLsStep5_USD1 = parseInt((($Count-20)/2)+0.5);}
					else { ExtraSpiderURLsStep5_USD1 = 0;}
					theForm.ExtraSpiderURLsStep5_USD1.value = ExtraSpiderURLsStep5_USD1;
					theForm.ExtraPromoURLsStep4_USD1.value=""+0;
					ExtraPromoURLsStep4_USD1 = 0;
               		PromoTotal = SEPromo + ExtraSpiderURLsStep5_USD1 + ExtraPromoURLsStep4_USD1;
				}else{
					theForm.ExtraSpiderURLsStep5_USD1.value=""+0;
				}
 				if( theForm.SEPromo.checked==true) {
					theForm.SESpider.checked=false;
					SEPromo = 1;
					var Count = WordCount(theForm.ListOfPromoURLs.value);
					if (Count>1) { ExtraPromoURLsStep4_USD1 = parseInt(((Count)));}
					else { theForm.ExtraPromoURLsStep4_USD1.value = ""+0;}
               PromoTotal = SEPromo + ExtraSpiderURLsStep5_USD1 + ExtraPromoURLsStep4_USD1;
				}
			   theForm.PromoTotal.value = "" + PromoTotal;
				if( theForm.monthlyRankCheck.checked==true ) {
					if( HostingFee<20) {monthlyRankCheck    = 1;}
					var Count = WordCount(theForm.ListOfRankURLs.value);
					if (Count>2) { ExtraRankURLsStep2 = parseInt( ((Count-2)/2) );}
					if (theForm.ExtraResultsStep100.value > 99 )
               { ExtraResultsStep100 = parseInt( (theForm.ExtraResultsStep100.value/100) ) * Count; }
					var Count = LineCount(theForm.RankSearchTerm.value);
					if (Count>1)         // if more than 1 search term
               {  monthlyRankCheck    = 1;
                  monthlyRankCheck    = ( monthlyRankCheck * Count );
                  if( HostingFee>8) { monthlyRankCheck    = monthlyRankCheck - 1;}
                  ExtraRankURLsStep2  = ( ExtraRankURLsStep2 * Count);
                  ExtraResultsStep100 = ( ExtraResultsStep100 * Count );
               }
					theForm.ExtraRankURLsStep2.value = "" + ExtraRankURLsStep2;
					theForm.ExtraRankResults.value   = "" + ExtraResultsStep100;
               RankCheckTotal                   = monthlyRankCheck + ExtraRankURLsStep2 +
                                                  ExtraResultsStep100;
					theForm.RankCheckTotal.value     = "" + RankCheckTotal;
				}else {
					theForm.RankCheckTotal.value  = "" + 0;
					theForm.ExtraRankURLsStep2.value  = "" + 0;
					theForm.ExtraResultsStep100.value = "" + 0;
					theForm.ExtraRankResults.value    = "" + 0;
				}
            HostingTotal = parseInt( HostingFee + MirrorServerUSD + WeeklyBackup + ExclusiveIP +
  								   SSLCertificate + ShellAccount + ExtraTraffic + ExtraSpace );

            if ( HostingFee < 1 && HostingTotal > 0 )
            {  theForm.WeeklyBackup.checked   = false;
				   theForm.SSLCertificate.checked = false;
				   //theForm.MirrorServer.checked   = false;
				   theForm.ExclusiveIP.checked    = false;
 				   theForm.ShellAccount.checked   = false;
 				   theForm.ExtraSpace.value       = "0";
 				   theForm.ExtraTraffic.value     = "0";
					alert("You can't have Hosting add-ons without selecting a Hosting Plan first!");
               theForm.WebHostingPlan.focus();
					return ;
				}


			   theForm.HostingTotal.value = "" + HostingTotal;

            var totalFee = parseInt( HostingTotal + PromoTotal + RankCheckTotal );

				var SixMonthFee    = parseInt((totalFee * 1 * 6)+((MailFee+SSLCertificate)/2)+0.5);
				var TwelveMonthFee = parseInt((totalFee * 1 * 12)+(MailFee+SSLCertificate));
				var TwentyfourMonthFee = parseInt(TwelveMonthFee * 0.90 * 2);
				var MonthFee       = parseInt(totalFee + ((MailFee+SSLCertificate)/12)+0.5);
				var BillingFee = MonthFee;

            if ( theForm.PayOffline.checked == true && theForm.PayOnline.checked == true)
            {  theForm.PayOffline.checked = false; }

         if ( theForm.PayOffline.checked == true)
         {
				if ((MonthFee+SetupFee) < 10 && theForm.PayMonth[0].checked==true) {
					theForm.PayMonth[0].checked=false;
					theForm.PayMonth[1].checked=true;
					theForm.PayMonth[2].checked=false;
				}
				if ((SixMonthFee+SetupFee) < 40 && theForm.PayMonth[2].checked==false
				     && theForm.PayMonth[3].checked==false) {
					theForm.PayMonth[0].checked=false;
					theForm.PayMonth[1].checked=false;
					theForm.PayMonth[2].checked=true;
				}
         }
				if( theForm.PayMonth[1].checked==true ){
					BillingFee = SixMonthFee;
					PayTerm = 6;
				}
				else if( theForm.PayMonth[2].checked==true ){
					SetupFee = 0;
					BillingFee = TwelveMonthFee;
					PayTerm = 12;
				}
				else if( theForm.PayMonth[3].checked==true ){
					SetupFee = 0;
					BillingFee = TwentyfourMonthFee;
					PayTerm = 24;
				}
				MonthFee = MonthFee;
				SixMonthFee         = SixMonthFee;
				TwelveMonthFee      = TwelveMonthFee;
				TwentyfourMonthFee  = TwentyfourMonthFee;
				BillingFee2         = BillingFee;
				BillingFee          += SetupFee;
				//BillingFee          = BillingFee;
				//BillingFee2         = BillingFee2;

				//theForm.SetupFee.value    = "" + SetupFee;
				//theForm.SetupFee2.value   = "" + SetupFee;
				theForm.MonthFee.value    = "" + MonthFee;
				theForm.SixMonthFee.value = "" + SixMonthFee;
				theForm.TwelveMonthFee.value     = "" + TwelveMonthFee;
				theForm.TwentyfourMonthFee.value = "" + TwentyfourMonthFee;
				//theForm.BillingFee.value       = BillingFee;
				theForm.BillingFee2.value        = "" + BillingFee2;
				theForm.PayTerm.value            = "" + PayTerm;
				//theForm.MirrorServerUSD.value    = "" + MirrorServerUSD;

				if (totalFee > 800){
					alert("Hehehe! I like this order! No kidding... if you are serious about this order, please mail us first!")
					return;
				}

				if (0){  //WebHostingPlan == "Plan P") {       // Plan P now separate order!
					theForm.return_link_url.value = theForm.courtesy_our_url.value;
					theForm.refresh.value = 0;

				} else {
					// Payment details for 2CheckOut
					var today = new Date();               // today's date
    				//theForm.cart_order_id.value = ""+ today.getMonth() + ""+ today.getDay() +"" +today.getMinutes(); //"1234678"; //
					//theForm.total.value = BillingFee;

               // if paying offline
               //theForm.PayOffline.checked = true;  // temp solution 11/03
               if ( theForm.PayOffline.checked == true && theForm.PayOnline.checked == false)
               {  theForm.forward.value = "/order/thankyou.php" }
               else
               {
                  theForm.forward.value =
                  "https://www.paypal.com/cgi-bin/webscr/?upload=1&business=Office%40CandiNet.com"+
                  "&item_name=Order+for+WebServices&item_number=WebServiceOrder"+
				  "&amount="+BillingFee+
                  "&upload=1"+
                  "&add=0"+
                  "&paymentaction="+
                  "&cmd=_cart"+
				  "&bn=PP-ShopCartBF"+
                  "&tax_cart=0"+
                  "&no_shipping=1&no_note="+
                  "&page_style=PayPal"+
                  "&currency_code=EUR"+
                  "&rm=2"+
                  "&return=http://BaliService.com/order/thankyou.php"+
                  "&cancel_return=http://BaliService.com/order/OrderCancellation.php"+
                  "&notify_url=http://BaliService.com/order/thankyou.php"+
                  "&shopping_url=http://BaliService.com/order/thankyou.php"
                  ;

                  //"&email=" + "" + theForm.email.value +
                  //"&phone=" + "" + theForm.phone.value +
                  //"&city=" + "" + theForm.city.value +
                  //"&zip=" + "" + theForm.zip.value +
                  //"&country=" + "" + theForm.country.value +
                  //"&street_address=" + "" + theForm.address.value;
               }
            }
}


function WordCount(inputString)
{
  return inputString.split(' ').length +
  		 inputString.split(',').length +
		 inputString.split('\n').length;
}

function LineCount(inputString)
{
  return inputString.split('\n').length;
}


function Form1_Validator(theForm)
{

 if (theForm.ConfirmContractConditions.value == "")
  {
    alert("Please enter \"Yes\" to adopt our policies in the \"Please type \"Yes\" to adopt our policies and service guidelines\" field.");
    theForm.ConfirmContractConditions.focus();
    return (false);
  }

  if (theForm.ConfirmContractConditions.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Please type \"Yes\" to adopt our policies and service guidelines\" field.");
    theForm.ConfirmContractConditions.focus();
    return (false);
  }

  if (theForm.ConfirmContractConditions.value.length > 3)
  {
    alert("Please enter at most 3 characters in the \"Please type \"Yes\" to adopt our policies and service guidelines\" field.");
    theForm.ConfirmContractConditions.focus();
    return (false);
  }


  var chkVal = theForm.ConfirmContractConditions.value;
  var prsVal = chkVal;
  if (chkVal != "" && ((prsVal == "Yes") || (prsVal == "yes")))
  {
    if ( parseInt(theForm.MonthFee.value) < 1 )
    {
       alert("No money no honey! Are You joking or just confused? Please try again!");
       theForm.WebHostingPlan.focus();
       return (false);
    }
    for (var i=0; i < theForm.length; i++) {theForm.elements[i].readonly = false; }
    theForm.ConfirmContractConditions.focus();
    return (true);
  }
    alert("Please enter \"Yes\" to confirm adoption of policies and service guidelines!");
  return (false);
}