//  Date: 02/01/2010 Name: SBCH_Buy.js//  Copyright 1994 - 2010 Scorpion Research Limited All Rights Reserved Worldwide//  eMail: Support@ScorpionResearch.com http://www.ScorpionResearch.com////  This document and its usage is protected under various Copyrights on behalf//  of its respective owners. No part of this document may be reproduced//  in whole or in part without the written consent of Scorpion Research Ltd.////  For further details, please send a message to Scorpion Research Ltd via eMail//  addressed to Support@ScorpionResearch.com specifying your particular//  requirements.function CalculateTax() {  foundtax = false;  TotalTax = 0.00;  TaxVATRegion=document.purchaseform.TaxVATRegion.options[document.purchaseform.TaxVATRegion.selectedIndex].text;  if (TaxVATRegion.toLowerCase() == 'uk resident') {    TotalTax=TaxableGoods*(17.5/100);    foundtax = true;  }  if (TaxVATRegion.toLowerCase() == 'ec resident') {    TotalTax=TaxableGoods*(17.5/100);    foundtax = true;  }  if (TaxVATRegion.toLowerCase() == 'ec resident vat registered') {    TotalTax=0.00;    foundtax = true;  }  if (TaxVATRegion.toLowerCase() == 'international') {    TotalTax=0.00;    foundtax = true;  }  if (foundtax == false) {    TotalTax = 0.00;  }  TempNum=TotalTax*100.00;  TempNum=Math.round(TempNum);  TotalTax=TempNum/100.00;  TempNum=0.00;  document.purchaseform.TaxRevised.value = FormatCurrency(true,TotalTax);  document.purchaseform.TaxTotal.value = FormatCurrency(true,TotalTax);  document.purchaseform.OrderRevised.value = FormatCurrency(true,TotalTax+TotalPrice);  document.purchaseform.OrderTotal.value = FormatCurrency(true,TotalTax+TotalPrice);}function FormatCurrency(displayCurrency,value) {  newString=0;  if (value < 0) {    isNegative=true;    value=value*(-1)  } else {    isNegative=false;  }  newPounds=parseInt(value);  if (value != 0) {    errorfactor=0.000008;    newPence=(value + errorfactor - newPounds)*100;    newPence=Math.round(newPence);  } else {    newPence=0;  }  if (eval(newPence) == 100) {    newPence=0;    newPounds=newPounds+1;  }  compstring='9';  if (eval(newPence) <= eval(compstring)) {    newPence='0'+newPence;  }  curPrefix='£'  curSuffix='';  if (displayCurrency != true) {    curPrefix='';    curSuffix='';  }  if (isNegative == true) {    curPrefix='-'+curPrefix;  }  newString=curPrefix + newPounds + '.' + newPence + curSuffix;  return (newString);}function PurchaseFormBuild() {  TotalPrice=99.00;  TaxableGoods=99.00;  TaxVATRegion='UK Resident';  PurchaseFormUpdate();}function PurchaseFormCheck()  {  if (document.purchaseform.eMailAddress.value == "") {    alert("Please include your eMail address!");    document.purchaseform.eMailAddress.focus();    return false;  }  if (document.purchaseform.eMailAddress.value.indexOf("@") == -1 || document.purchaseform.eMailAddress.value.length <= 5)  {    alert("Please include a proper Internet eMail address!");    document.purchaseform.eMailAddress.focus();    return false;  }  if (document.purchaseform.FullName.value == "")  {    alert("Please enter your Full Name!");    document.purchaseform.FullName.focus();    return false;  }  if (document.purchaseform.Street.value == "")  {    alert("Please enter the name of your Street!");    document.purchaseform.Street.focus();    return false;  }  if (document.purchaseform.City.value == "")  {    alert("Please enter the name of your City!");    document.purchaseform.City.focus();    return false;  }  if (document.purchaseform.Code.value == "")  {    alert("Please enter your postal Code!");    document.purchaseform.Code.focus();    return false;  }  if (document.purchaseform.Country.value == "")  {    alert("Please enter the name of your Country!");    document.purchaseform.Country.focus();    return false;  }  if (document.purchaseform.Tel.value == "")  {    alert("Please enter your Telephone number!");    document.purchaseform.Tel.focus();    return false;  }  if (document.purchaseform.PayMethod.options[document.purchaseform.PayMethod.selectedIndex].value == 'CreditCard') {    CardNumber=document.purchaseform.CCNumber.value;    if (VerifyCardNum(CardNumber) != true) {      alert("Your Card Number does not appear to be correct!");      document.purchaseform.CCNumber.focus();      return false;    }    if (document.purchaseform.CCExpDate.value == "") {      alert("Please enter the Expiry Date of your card!");      document.purchaseform.CCExpDate.focus();      return false;    }    if (document.purchaseform.CCSecCC.value != "") {      if (document.purchaseform.CCSecCC.value.length < 3 || document.purchaseform.CCSecCC.value.length > 4) {        alert("Please enter your Security Code exactly as it appears on your card!");        document.purchaseform.CCSecCC.focus();        return false;      }      if ((document.purchaseform.CCCreditCard.options[document.purchaseform.CCCreditCard.selectedIndex].value == "Amex") && (document.purchaseform.CCSecCC.value.length != 4)) {        alert("American Express Cards have a 4 digit Security Code printed on the front of the card.");        document.purchaseform.CCSecCC.focus();        return false;      }      if ((document.purchaseform.CCCreditCard.options[document.purchaseform.CCCreditCard.selectedIndex].value != "Amex") && (document.purchaseform.CCSecCC.value.length != 3)) {        alert("Visa/MasterCard and most other card issuers place a 3 digits Security Code as the last 3 digits on the signature strip located on the rear of the card.");        document.purchaseform.CCSecCC.focus();        return false;      }    } else {      alert("Please enter your Security Code exactly as it appears on your card!");      document.purchaseform.CCSecCC.focus();      return false;    }    if (document.purchaseform.CCName.value == "") {      alert("Please enter your Name exactly as it appears on your card!");      document.purchaseform.CCName.focus();      return false;    }  }  if ((document.purchaseform.VATRegCountry.options[document.purchaseform.VATRegCountry.selectedIndex].value == "") && (document.purchaseform.TaxVATRegion.options[document.purchaseform.TaxVATRegion.selectedIndex].text == "EC Resident VAT Registered")) {    alert("You have claimed exemption from VAT because you are registered for VAT in another EC country but you have not specified which country. Please specify the Country where you are registered for VAT!");    return false;  }  if (document.purchaseform.TaxVATRegion.options[document.purchaseform.TaxVATRegion.selectedIndex].text == "EC Resident VAT Registered") {    VATNumber=document.purchaseform.VATRegNumber.value;    VATCountry=document.purchaseform.VATRegCountry.options[document.purchaseform.VATRegCountry.selectedIndex].value    if (VerifyECVATNumber(VATNumber,VATCountry) != true) {      alert("Your VAT Number does not appear to be correct!");      document.purchaseform.VATRegNumber.focus();      return false;    }  }  RemindPayMethod();  TransferProtocol=self.location.protocol.toLowerCase();  if (TransferProtocol.indexOf('http') == -1) {    alert('Sorry, you do not appear to be connected to the Server and the purchase system cannot operate in an Offline mode!');    return false;  }  PurchaseFormClearDisabled();}function PurchaseFormClearDisabled() {  PurchaseFormUpdate();  document.purchaseform.GoodsRevised.value = '';  document.purchaseform.TaxRevised.value = '';  document.purchaseform.OrderRevised.value = '';}function PurchaseFormUpdate() {  document.purchaseform.GoodsRevised.value = FormatCurrency(true,TotalPrice);  document.purchaseform.GoodsTotal.value = FormatCurrency(true,TotalPrice);  CalculateTax();}function RemindButtonPrint() {  window.print();  if (document.purchaseform.PayMethod.options[document.purchaseform.PayMethod.selectedIndex].value == "CashCheque") {    alert("Please remember to send a copy of this printed Form with your Cheque payment!");  }}function RemindECVATNrNeeded() {  if (document.purchaseform.TaxVATRegion.options[document.purchaseform.TaxVATRegion.selectedIndex].text == "EC Resident VAT Registered") {    alert("To claim exemption from EC VAT Sales Tax, please remember to enter your valid EC Registration Number in the Payment Form!");  }}function RemindPayMethod() {  if (document.purchaseform.PayMethod.options[document.purchaseform.PayMethod.selectedIndex].value == "CashCheque") {    alert("You have chosen to pay by Cheque. Please remember to send a printed copy of this Form with your Cheque payment!");  }}function UpdateDataFields(BlurredField) {  BlurredFieldName='';  if (BlurredField==1) {    BlurredFieldName='Goods Value';  }  if (BlurredField==2) {    BlurredFieldName='Tax Charged';  }  if (BlurredField==3) {    BlurredFieldName='Total Value';  }  if (BlurredFieldName != '') {    result=alert('Amending the '+BlurredFieldName+' could invalidate your totals! To prevent delays in processing your order, you may wish to add further details using the Comment box below.');  }}function VerifyCardNum(CardNumber) {  CardData='';  for (i = 0; i < CardNumber.length; i++) {    TestChar = CardNumber.charAt(i);    if ((TestChar >= "0") && (TestChar <= "9")) {      CardData += CardNumber.charAt(i);    }  }  if (CardData.length > 9) {    CheckDigit=0;    for (i = 1; i <= CardData.length; i++) {      CharPosition=CardData.length-i;      TestChar = CardData.charAt(CharPosition);      Mod2Result=(i-((parseInt(i/2))*2));      if (Mod2Result == 0) {        MultiplierValue=2*eval(TestChar);        if (MultiplierValue > 9) {          MultiplierValue=MultiplierValue-9;        }      } else {        MultiplierValue=eval(TestChar);      }      CheckDigit=CheckDigit+MultiplierValue;    }  } else {    CheckDigit=1;  }  Mod10Result=(CheckDigit-((parseInt(CheckDigit/10))*10));  if (Mod10Result != 0) {    return false;  } else {    return true;  }}function VerifyECVATNumber(VATNumber,VATCountry) {  VATData='';  VATInfo='';  VATValid=false;  for (i = 0; i < VATNumber.length; i++) {    TestChar = VATNumber.charAt(i);    TestChar = TestChar.toUpperCase();    if ((TestChar >= "0") && (TestChar <= "9")) {      VATData += TestChar;      VATInfo += TestChar;    }    if ((TestChar >= "A") && (TestChar <= "Z")) {      VATInfo += TestChar;    }  }  if (VATCountry == "AT") {    TestChar = VATInfo.charAt(0);    TestChar = TestChar.toUpperCase();    if ((TestChar == "U") && (VATData.length == 8) && (VATInfo.length == 9)) {      VATValid=true;    }  }  if (VATCountry == "BE") {    if ((VATData.length == 10) && (VATInfo.length == 10)) {      VATValid=true;    }  }  if (VATCountry == "BG") {    if ((VATData.length == 9) && (VATInfo.length == 9)) {      VATValid=true;    }    if ((VATData.length == 10) && (VATInfo.length == 10)) {      VATValid=true;    }  }  if (VATCountry == "CY") {    TestChar = VATInfo.charAt(8);    TestChar = TestChar.toUpperCase();    if ((TestChar >= "A") && (TestChar <= "Z") && (VATData.length == 8) && (VATInfo.length == 9)) {      VATValid=true;    }  }  if (VATCountry == "CZ") {    if ((VATData.length == 8) && (VATInfo.length == 8)) {      VATValid=true;    }    if ((VATData.length == 9) && (VATInfo.length == 9)) {      VATValid=true;    }    if ((VATData.length == 10) && (VATInfo.length == 10)) {      VATValid=true;    }  }  if (VATCountry == "DE") {    if ((VATData.length == 9) && (VATInfo.length == 9)) {      VATValid=true;    }  }  if (VATCountry == "DK") {    if ((VATData.length == 8) && (VATInfo.length == 8)) {      VATValid=true;    }  }  if (VATCountry == "EE") {    if ((VATData.length == 9) && (VATInfo.length == 9)) {      VATValid=true;    }  }  if (VATCountry == "EL") {    if ((VATData.length == 9) && (VATInfo.length == 9)) {      VATValid=true;    }  }  if (VATCountry == "ES") {    TestChar = VATInfo.charAt(0);    TestChar = TestChar.toUpperCase();    if ((TestChar >= "A") && (TestChar <= "Z") && (VATData.length == 8) && (VATInfo.length == 9)) {      VATValid=true;    }    TestChar = VATInfo.charAt(8);    TestChar = TestChar.toUpperCase();    if ((TestChar >= "A") && (TestChar <= "Z") && (VATData.length == 8) && (VATInfo.length == 9)) {      VATValid=true;    }    TestChar = VATInfo.charAt(0);    TestChar = TestChar.toUpperCase();    if ((TestChar >= "A") && (TestChar <= "Z") && (VATData.length == 7) && (VATInfo.length == 9)) {      TestChar = VATInfo.charAt(8);      TestChar = TestChar.toUpperCase();      if ((TestChar >= "A") && (TestChar <= "Z") && (VATData.length == 7) && (VATInfo.length == 9)) {        VATValid=true;      }    }  }  if (VATCountry == "FI") {    if ((VATData.length == 8) && (VATInfo.length == 8)) {      VATValid=true;    }  }  if (VATCountry == "FR") {    if ((VATData.length == 11) && (VATInfo.length == 11)) {      VATValid=true;    }    TestChar = VATInfo.charAt(0);    TestChar = TestChar.toUpperCase();    if ((TestChar >= "A") && (TestChar <= "Z") && (VATData.length == 10) && (VATInfo.length == 11) && (TestChar != "O") && (TestChar != "I")) {      VATValid=true;    }    TestChar = VATInfo.charAt(1);    TestChar = TestChar.toUpperCase();    if ((TestChar >= "A") && (TestChar <= "Z") && (VATData.length == 10) && (VATInfo.length == 11) && (TestChar != "O") && (TestChar != "I")) {      VATValid=true;    }    TestChar = VATInfo.charAt(0);    TestChar = TestChar.toUpperCase();    if ((TestChar >= "A") && (TestChar <= "Z") && (VATData.length == 9) && (VATInfo.length == 11) && (TestChar != "O") && (TestChar != "I")) {      TestChar = VATInfo.charAt(1);      TestChar = TestChar.toUpperCase();      if ((TestChar >= "A") && (TestChar <= "Z") && (VATData.length == 9) && (VATInfo.length == 11) && (TestChar != "O") && (TestChar != "I")) {        VATValid=true;      }    }  }  if (VATCountry == "GB") {    if ((VATData.length == 9) && (VATInfo.length == 9)) {      VATValid=true;    }    if ((VATData.length == 12) && (VATInfo.length == 12)) {      VATValid=true;    }    if ((VATData.length == 3) && (VATInfo.length == 5)) {      VATPref = VATInfo.charAt(0) + VATInfo.charAt(1);      VATPref = VATPref.toUpperCase();      if (VATPref == "GD") {        VATValid=true;      }    }    if ((VATData.length == 3) && (VATInfo.length == 5)) {      VATPref = VATInfo.charAt(0) + VATInfo.charAt(1);      VATPref = VATPref.toUpperCase();      if (VATPref == "HA") {        VATValid=true;      }    }  }  if (VATCountry == "HU") {    if ((VATData.length == 8) && (VATInfo.length == 8)) {      VATValid=true;    }  }  if (VATCountry == "IE") {    TestChar = VATInfo.charAt(7);    TestChar = TestChar.toUpperCase();    if ((TestChar >= "A") && (TestChar <= "Z") && (VATData.length == 7) && (VATInfo.length == 8)) {      VATValid=true;    }    TestChar = VATInfo.charAt(7);    TestChar = TestChar.toUpperCase();    if ((TestChar >= "A") && (TestChar <= "Z") && (VATData.length == 6) && (VATInfo.length == 8)) {      TestChar = VATInfo.charAt(1);      TestChar = TestChar.toUpperCase();      if ((TestChar >= "A") && (TestChar <= "Z") && (VATData.length == 6) && (VATInfo.length == 8)) {        VATValid=true;      }    }  }  if (VATCountry == "IT") {    if ((VATData.length == 11) && (VATInfo.length == 11)) {      VATValid=true;    }  }  if (VATCountry == "LT") {    if ((VATData.length == 9) && (VATInfo.length == 9)) {      VATValid=true;    }    if ((VATData.length == 12) && (VATInfo.length == 12)) {      VATValid=true;    }  }  if (VATCountry == "LU") {    if ((VATData.length == 8) && (VATInfo.length == 8)) {      VATValid=true;    }  }  if (VATCountry == "LV") {    if ((VATData.length == 11) && (VATInfo.length == 11)) {      VATValid=true;    }  }  if (VATCountry == "MT") {    if ((VATData.length == 8) && (VATInfo.length == 8)) {      VATValid=true;    }  }  if (VATCountry == "NL") {    TestChar = VATInfo.charAt(9);    TestChar = TestChar.toUpperCase();    if ((TestChar == "B") && (VATData.length == 11) && (VATInfo.length == 12)) {      VATValid=true;    }  }  if (VATCountry == "PL") {    if ((VATData.length == 10) && (VATInfo.length == 10)) {      VATValid=true;    }  }  if (VATCountry == "PT") {    if ((VATData.length == 9) && (VATInfo.length == 9)) {      VATValid=true;    }  }  if (VATCountry == "RO") {    if ((VATData.length >= 2) && (VATData.length <= 10) && (VATData.length == VATInfo.length)) {      VATValid=true;    }  }  if (VATCountry == "SE") {    if ((VATData.length == 12) && (VATInfo.length == 12)) {      VATValid=true;    }  }  if (VATCountry == "SI") {    if ((VATData.length == 8) && (VATInfo.length == 8)) {      VATValid=true;    }  }  if (VATCountry == "SK") {    if ((VATData.length == 10) && (VATInfo.length == 10)) {      VATValid=true;    }  }  return VATValid;}function WindowButtonPrint() {  TextChar39="'";  BrowserName = navigator.appName;  BrowserVers = parseInt(navigator.appVersion);  if (BrowserName == "Netscape" && BrowserVers >= 3) {    document.writeln('<INPUT TYPE=BUTTON NAME="Print" VALUE="Print" ONCLICK='+TextChar39+'RemindButtonPrint();'+TextChar39+' TITLE="Click Here To Print This Order">');  }}