      function ValidateForm()
      {
        var Name      = (document.getElementById('txtName').value);
        var Address   = (document.getElementById('txtAddress').value);
        var State     = (document.getElementById('txtState').value);
        var City      = (document.getElementById('txtCity').value);
        var Postcode  = (document.getElementById('txtPostcode').value);
        var Telephone = (document.getElementById('txtPhone').value);
        var Email = (document.getElementById('txtEmail').value);
        var GrandTotal = (Curry2Dec(document.getElementById('txtGrandTotal').value) * 1);

        var Message = "Sorry, you must fill in the following fields: \n";

        if (Name.length < 3)
        {
          Message = Message + "- Name \n";
        }
        if (Address.length < 5)
        {
          Message = Message + "- Address \n";
        }
        if (State.length < 2)
        {
          Message = Message + "- State \n";
        }
        if (City.length < 2)
        {
          Message = Message + "- City \n";
        }
        if (Postcode.length < 1)
        {
          Message = Message + "- Postcode \n";
        }
        if (Telephone.length < 5)
        {
          Message = Message + "- Telephone Number \n";
        }
        if (Email.length < 5 || Email.indexOf('@') < 1)
        {
          Message = Message + "- Email Address \n";
        }
        if (GrandTotal <= 0)
        {
          Message = Message + "- Select at least 1 product \n";
        }

        if (Message == "Sorry, you must fill in the following fields: \n")
        {
//          alert('OK');
          return true;
        }
        else
        {
          alert(Message);
          return false;
        }

      }


      function generate_address( username, hostname ) {
        var domain = ".com";
        var atsign = "&#64;";
        var addr = username + atsign + hostname + domain;
        document.write(
          "<" + "a" + " " + "href=" + "mail" + "to:" + addr + ">" +
          addr +
          "<\/a>");
      }
      function UpdateTotal (productindex)
      {
        Quantity = (document.getElementById('txt_qty' + productindex).value * 1);
        Price = (document.getElementById('hdn_price' + productindex).value * 1);
        ProductCount = (document.getElementById('hdnProductCount').value * 1);

        if (IsNumeric(Quantity))
        {
          if (Quantity > 0)
          {
            document.getElementById('txt_total' + productindex).value = formatMyCurrency(Quantity * Price);
          }
          else
          {
            document.getElementById('txt_total' + productindex).value = formatMyCurrency(0);
          }
        }
        else
        {
          document.getElementById('txt_total' + productindex).value = formatMyCurrency(0);
        }
        GrandTotal = 0;
        for (CurrentProduct=0;CurrentProduct<ProductCount;CurrentProduct++)
        {
          GrandTotal += (Curry2Dec(document.getElementById('txt_total' + CurrentProduct).value) * 1);
        }
          document.getElementById('txtGrandTotal').value = formatMyCurrency(GrandTotal);

      }
    
    function Curry2Dec(varCurrency)
    {
      varCurrency = replace(varCurrency, "," , "");
      varCurrency = replace(varCurrency, "$" , "");
      return varCurrency;
    }

    function formatMyCurrency(num)
    {
      num = num.toString().replace(/\\\$|\\,/g,'');
      if(isNaN(num))
      {
       num = "0";
      }
      sign = (num == (num = Math.abs(num)));
      num = Math.floor(num*100+0.50000000001);
      cents = num%100;
      num = Math.floor(num/100).toString();
      if(cents<10)
      {
       cents = "0" + cents;
      }
      for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
      num = num.substring(0,num.length-(4*i+3))+','+
      num.substring(num.length-(4*i+3));
      return (((sign)?'':'-') + '$'+ num + '.' + cents);
    }
    function replace(string,text,by) 
    {
      // Replaces text with by in string
      var strLength = string.length, txtLength = text.length;
      if ((strLength == 0) || (txtLength == 0)) return string;
  
      var i = string.indexOf(text);
      if ((!i) && (text != string.substring(0,txtLength))) return string;
      if (i == -1) return string;
  
      var newstr = string.substring(0,i) + by;
  
      if (i+txtLength < strLength)
          newstr += replace(string.substring(i+txtLength,strLength),text,by);
  
      return newstr;
    }

   //  check for valid numeric strings
   function IsNumeric(strString)
   {
     var strValidChars = "0123456789.-";
     var strChar;
     var blnResult = true;
  
     if (strString.length == 0) return false;
  
     //  test strString consists of valid characters listed above
     for (i = 0; i < strString.length && blnResult == true; i++)
        {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
           {
           blnResult = false;
           }
        }
     return blnResult;
   }




    //-->
