function Calculate(TheForm, OCPrice, DSPrice, AEPrice, CRPrice, CPPrice, DUPrice, DWPrice)
{
  // Verify the Qty
  var Qty;
  //Qty = parseInt(TheForm.OC.value); if(Qty >= 0) TheForm.OC.value = Qty; else TheForm.OC.value = "";
  Qty = parseInt(TheForm.DS.value); if(Qty >= 0) TheForm.DS.value = Qty; else TheForm.DS.value = "";
  Qty = parseInt(TheForm.AE.value); if(Qty >= 0) TheForm.AE.value = Qty; else TheForm.AE.value = "";
  //--------------------
  // enlever du site web
  Qty = parseInt(TheForm.CR.value); if(Qty >= 0) TheForm.CR.value = Qty; else TheForm.CR.value = "";
  Qty = parseInt(TheForm.CP.value); if(Qty >= 0) TheForm.CP.value = Qty; else TheForm.CP.value = "";
  Qty = parseInt(TheForm.DU.value); if(Qty >= 0) TheForm.DU.value = Qty; else TheForm.DU.value = "";
  //Qty = parseInt(TheForm.DW.value); if(Qty >= 0) TheForm.DW.value = Qty; else TheForm.DW.value = "";

  // Calculate the total
  var PriceOC = 0;//parseInt(eval(TheForm.OC.value * OCPrice * 100));
  var PriceDS = parseInt(eval(TheForm.DS.value * DSPrice * 100));
  var PriceAE = parseInt(eval(TheForm.AE.value * AEPrice * 100));
  //--------------------
  // enlever du site web
  var PriceCR = parseInt(eval(TheForm.CR.value * CRPrice * 100));
  var PriceCP = parseInt(eval(TheForm.CP.value * CPPrice * 100));
  var PriceDU = parseInt(eval(TheForm.DU.value * DUPrice * 100));
  var PriceDW = 0;//parseInt(eval(TheForm.DW.value * DWPrice * 100));
  var Price = parseInt(eval(/*PriceOC + */PriceDS + PriceAE + PriceCR + PriceCP + PriceDU/* + PriceDW*/));
  var RealPrice = Price;

  // Set the RealTotal
  TheForm.RealTotal.value = parseInt(eval(RealPrice / 100));
  RealPrice = parseInt(eval(RealPrice % 100));
  if(RealPrice < 10)
    TheForm.RealTotal.value += ".0" + parseInt(RealPrice);
  else
    TheForm.RealTotal.value += "." + parseInt(RealPrice);
  
  // Set the new total
  //TheForm.TotalOC.value = "US$ " + parseInt(eval(PriceOC / 100));
  //PriceOC = parseInt(eval(PriceOC % 100));
  //if(PriceOC < 10)
  //  TheForm.TotalOC.value += ".0" + parseInt(PriceOC);
  //else
 //   TheForm.TotalOC.value += "." + parseInt(PriceOC);
  
  TheForm.TotalDS.value = "$ " + parseInt(eval(PriceDS / 100));
  PriceDS = parseInt(eval(PriceDS % 100));
  if(PriceDS < 10)
    TheForm.TotalDS.value += ".0" + parseInt(PriceDS);
  else
    TheForm.TotalDS.value += "." + parseInt(PriceDS);
  
  TheForm.TotalAE.value = "$ " + parseInt(eval(PriceAE / 100));
  PriceAE = parseInt(eval(PriceAE % 100));
  if(PriceAE < 10)                                  
    TheForm.TotalAE.value += ".0" + parseInt(PriceAE);
  else
    TheForm.TotalAE.value += "." + parseInt(PriceAE);
  //--------------------
  // enlever du site web
  
  TheForm.TotalCR.value = "$ " + parseInt(eval(PriceCR / 100));
  PriceCR = parseInt(eval(PriceCR % 100));
  if(PriceCR < 10)
    TheForm.TotalCR.value += ".0" + parseInt(PriceCR);
  else
    TheForm.TotalCR.value += "." + parseInt(PriceCR);
  
  TheForm.TotalCP.value = "$ " + parseInt(eval(PriceCP / 100));
  PriceCP = parseInt(eval(PriceCP % 100));
  if(PriceCP < 10)
    TheForm.TotalCP.value += ".0" + parseInt(PriceCP);
  else
    TheForm.TotalCP.value += "." + parseInt(PriceCP);

  TheForm.TotalDU.value = "$ " + parseInt(eval(PriceDU / 100));
  PriceDU = parseInt(eval(PriceDU % 100));
  if(PriceDU < 10)
    TheForm.TotalDU.value += ".0" + parseInt(PriceDU);
  else
    TheForm.TotalDU.value += "." + parseInt(PriceDU);
    
  /*
  TheForm.TotalDW.value = "$ " + parseInt(eval(PriceDW / 100));
  PriceDW = parseInt(eval(PriceDW % 100));
  if(PriceDW < 10)
    TheForm.TotalDW.value += ".0" + parseInt(PriceDW);
  else
    TheForm.TotalDW.value += "." + parseInt(PriceDW);
  */
  TheForm.Total.value = "$ " + parseInt(eval(Price / 100));
  Price = parseInt(eval(Price % 100));
  if(Price < 10)
    TheForm.Total.value += ".0" + parseInt(Price);
  else
    TheForm.Total.value += "." + parseInt(Price);
} 

function ChangeDesc(Title,Desc)
{
  var PopupTitle = document.getElementById('PopupTitle').firstChild;
  var PopupDesc = document.getElementById('PopupDesc').firstChild;
  
  PopupTitle.replaceData(0,PopupTitle.nodeValue.length,Title);
  PopupDesc.replaceData(0,PopupDesc.nodeValue.length,Desc);
}

function SomethingToBuy(/*OC,*/DS,AE,CR,CP,DU/*,DW*/)
{
  if(/*((OC.value == "0") || (OC.value == "")) && */((DS.value == "0") || (DS.value == "")) && ((AE.value == "0") || (AE.value == "")) && ((CR.value == "0") || (CR.value == "")) && ((CP.value == "0") || (CP.value == "")) && ((DU.value == "0") || (DU.value == "")) /*&& ((DW.value == "0") || (DW.value == ""))*/)
  //if(/*((OC.value == "0") || (OC.value == "")) && */((DS.value == "0") || (DS.value == "")) && ((AE.value == "0") || (AE.value == "")))
  {
    alert("No product was properly selected for purchase");
    return(false);
  }
  
  return(true);
}

function CountryOk(Country)
{
  if(Country.options[Country.selectedIndex].value=="")
  {
    alert('\nPlease select your country.');
    Country.focus();
  }
  else if((Country.options[Country.selectedIndex].value == 'afghanistan') || (Country.options[Country.selectedIndex].value == 'iran') || (Country.options[Country.selectedIndex].value == 'cuba') || (Country.options[Country.selectedIndex].value == 'libya') || (Country.options[Country.selectedIndex].value == 'syria') || (Country.options[Country.selectedIndex].value == 'sudan') || (Country.options[Country.selectedIndex].value == 'vietnam') || (Country.options[Country.selectedIndex].value == 'koreanorth')  )
  {
    alert('\nYou may not download our encryption product from this Country');
    document.location.replace("./index.htm");
  }
  else
    return(true);
  
  return(false);
}

function Buy(TheForm)
{                                                    //--------------------
  										   // enlever du site web
  if(!SomethingToBuy(/*TheForm.OC,*/TheForm.DS,TheForm.AE,TheForm.CR,TheForm.CP,TheForm.DU/*,TheForm.DW*/))
    return;
  
  if((!CountryOk(TheForm.Country)) || (!NameOk(TheForm.Name)) || (!EmailOk(TheForm.Email,TheForm.Confirmation)))
    return;
    
  //--------------------
  // enlever du site web
  
  if((parseInt(TheForm.DU.value) >= 1) && (parseInt(TheForm.CP.value) < 1) && !confirm('You are buying DUSK Corporate, but no Administrator Module for it. Do you want to continue anyway?'))
      return;
  
  var now = new Date();
  var year = now.getYear() + 1900;
  var day = now.getDay();
  var month = now.getMonth();
  var date_ = now.getDate();
  var whc = Math.random().toString();
  var ww = whc.charAt(5);
  var ww2 = whc.charAt(3);
  var uidd = (year + day + month + date_ + ww + whc + ww2);
  //--------------------
  // enlever du site web
  //var Product = TheForm.OC.value + '-' + TheForm.DS.value + '-' + TheForm.AE.value + '-' + TheForm.CR.value + '-' + TheForm.CP.value + '-' + TheForm.DU.value + '-' + TheForm.DW.value;
  var Product = /*TheForm.OC.value + */'0' + '-' + TheForm.DS.value + '-' + TheForm.AE.value + '-' + TheForm.CR.value + '-' + TheForm.CP.value + '-' + TheForm.DU.value + '-' + '0';
  var Total = TheForm.RealTotal.value;
  var Notify = (TheForm.Notify.checked == true)?"on":"off";

  order_info = 'ThanksURL=http:%2f%2fwww.deltacrypt.com%2fphp%2fCreateAccount.php%3Fc=Accept%5elanguage=english%5eaccess_type=purchase%5eemail=' + TheForm.Email.value + '%5ename=' + TheForm.Name.value + '%5ecountry=' + TheForm.Country.value + '%5enotify=' + Notify + '%5eproduct='+ Product + '%5enumber=' + TheForm.ID.value +
	        '&NoThanksURL=http:%2f%2fwww.deltacrypt.com%2fphp%2fCreateAccount.php%3Faccess_type=purchase%5ec=Declined%5elanguage=english';
  order_info = order_info.replace(/ /g,"*");
  	//order_info = 'https://order.psigate.com/psigatestandard.asp?MerchantID=deltacrypttech&Bname='+ TheForm.Name.value + '&FullTotal=' + Total + '&Oid=' + uidd + '&Email=' + TheForm.Email.value + '&ChargeType=0&' + order_info;
	order_info = 'https://checkout.psigate.com/HTMLPost/HTMLMessenger?StoreKey=DeltacryptusdxQVrfR007639&Bname='+ TheForm.Name.value + '&FullTotal=' + Total + '&Oid=' + uidd + '&Email=' + TheForm.Email.value + '&ChargeType=0&' + order_info;
  document.location=order_info;
  //TheForm.Command.value = order_info;
}

function BuyElavon(TheForm)
{                                                    //--------------------
  if(!SomethingToBuy(/*TheForm.OC,*/TheForm.DS,TheForm.AE,TheForm.CR,TheForm.CP,TheForm.DU/*,TheForm.DW*/))
    return;

  if((!CountryOk(TheForm.ssl_country)) || (!NameOk(TheForm.ssl_first_name)) || (!EmailOk(TheForm.ssl_email,TheForm.Confirmation)) || (!CreditCardNumberOk(TheForm.ssl_card_number)) || (!CreditCardExpDateOk(TheForm.ssl_exp_date)))
    return;
  //--------------------
  // enlever du site web

  if((parseInt(TheForm.DU.value) >= 1) && (parseInt(TheForm.CP.value) < 1) && !confirm('You are buying DUSK Corporate, but no Administrator Module for it. Do you want to continue anyway?'))
    return;

  var now = new Date();
  var year = now.getYear() + 1900;
  var day = now.getDay();
  var month = now.getMonth();
  var date_ = now.getDate();
  var whc = Math.random().toString();
  var ww = whc.charAt(5);
  var ww2 = whc.charAt(3);
  var uidd = (year + day + month + date_ + ww + whc + ww2);
  // Configuration de base
  var BaseParams =  'ssl_show_form=false' +
  				'&ssl_transaction_type=ccsale' +
  				'&ssl_receipt_apprvl_method=REDG' +
  				'&ssl_receipt_decl_method=REDG' +
  				'&ssl_result_format=HTML' +
			  	'&ssl_pin=AT3REQ' +
				'&ssl_user_id=website' +
				'&ssl_merchant_id=513739' +
				'&ssl_error_url=http://www.deltacrypt.com/english/home/Message.php';

  var Product = '0' + '-' + TheForm.DS.value + '-' + TheForm.AE.value + '-' + TheForm.CR.value + '-' + TheForm.CP.value + '-' + TheForm.DU.value + '-' + '0';
  var Total = TheForm.RealTotal.value.substr(2);
  var Notify = (TheForm.Notify.checked == true)?"on":"off";

  // Config with parameters
  order_info = '&ssl_receipt_decl_get_url=http://www.deltacrypt.com/php/CreateAccount.php?language=english'+
		   	'&ssl_card_number=' + TheForm.ssl_card_number.value +
		   	'&ssl_exp_date=' + TheForm.ssl_exp_date.value +
  			'&ssl_receipt_apprvl_get_url=http://www.deltacrypt.com/php/CreateAccount.php?c=Accept' +
  	        	'^language=english' +
  			'^access_type=purchase' +
  			'^email=' + TheForm.ssl_email.value +
  			'^name=' + TheForm.ssl_first_name.value +
  			'^country=' + TheForm.ssl_country.value +
  			'^notify=' + Notify +
  			'^product=' + Product;


  order_info = order_info.replace(/ /g,"*");

  // when the period of test will finish, keep just: order_info += '&ssl_test_mode=false';   
  order_info = 'https://www.myvirtualmerchant.com/VirtualMerchant/process.do?' +
  	BaseParams +
  	'&ssl_first_name=' + TheForm.ssl_first_name.value +
  	'&ssl_amount=' + Total +
  	'&ssl_invoice_number=' + uidd +
  	'&ssl_email=' + TheForm.ssl_email.value + order_info;

  document.location = order_info;
}

function BuyElavonOrder(TheForm)
{                                                    

  var now = new Date();
  var year = now.getYear() + 1900;
  var day = now.getDay();
  var month = now.getMonth();
  var date_ = now.getDate();
  var whc = Math.random().toString();
  var ww = whc.charAt(5);
  var ww2 = whc.charAt(3);
  var uidd = (year + day + month + date_ + ww + whc + ww2);
  // Configuration de base
  var BaseParams =  'ssl_show_form=false' +
  				'&ssl_transaction_type=ccsale' +
  				'&ssl_receipt_apprvl_method=REDG' +
  				'&ssl_receipt_decl_method=REDG' +
  				'&ssl_result_format=HTML' +
			  	'&ssl_pin=AT3REQ' +
				'&ssl_user_id=website' +
				'&ssl_merchant_id=513739' +
				'&ssl_error_url=http://www.deltacrypt.com/english/home/Message.php';

  var Total = TheForm.RealTotal.value.substr(2);
  var Notify = (TheForm.Notify.checked == true)?"on":"off";

  // Config with parameters
  order_info = '&ssl_receipt_decl_get_url=http://www.deltacrypt.com/php/CreateAccount.php?language=english'+
		   	'&ssl_card_number=' + TheForm.ssl_card_number.value +
		   	'&ssl_exp_date=' + TheForm.ssl_exp_date.value +
  			'&ssl_receipt_apprvl_get_url=http://www.deltacrypt.com/php/thanks.php' ;



  order_info = order_info.replace(/ /g,"*");

  // when the period of test will finish, keep just: order_info += '&ssl_test_mode=false';   
  order_info = 'https://www.myvirtualmerchant.com/VirtualMerchant/process.do?' +
  	BaseParams +
  	'&ssl_first_name=' + TheForm.ssl_first_name.value +
  	'&ssl_amount=' + TheForm.ssl_amount.value +
  	'&ssl_invoice_number=' + TheForm.ssl_invoice_number.value +
  	'&ssl_company=' + TheForm.ssl_company.value +
  	'&ssl_email=' + TheForm.ssl_email.value + order_info;

  document.location = order_info;
}
