<!--
//********************Add page specific javascript here**************************
function processDiscount(val){
var bOK = true
if (!document.getElementById || !document.getElementsByTagName || !document.createElement) {
alert("Your browser settings will not allow this page to process.")
return;
}
if(val==0){
var disc = document.forms["Discount"].discountCode.value;
	if (disc.length<=0 || disc.length>20){
	bOK = false
	var DiscError = document.getElementById("errorDiscount");
	DiscError.className="errorShow";
	var skip  = document.getElementById("skip");
	skip.className="errorShow";
	document.forms["Discount"].discountCode.value="";
	document.forms["Discount"].discountCode.focus;
	}else{
	var DiscError = document.getElementById("errorDiscount");
	DiscError.className="errorHide";
	var skip  = document.getElementById("skip");
	skip.className="errorHide";
	document.forms["Discount"].action="RW24U_Order.asp?discount=on";
	document.forms["Discount"].submit();
	}
}else{
document.forms["Discount"].action="RW24U_Order.asp?discount=off";
document.forms["Discount"].submit();
}
}

function whatsThis(path){
// Name the Window, so the remote can target it -- for use with a close button in the future
self.name = "Parent_Window";
var helpwin = path;
var helpprop = "scrollbars,resizable,height=360,width=364,top=125, left=400";
var OpenWindow = window.open(helpwin, "", helpprop);
if (OpenWindow.blur) {
OpenWindow.focus();
}
return (true)
}

function enableSubmit(){
document.forms["Sales"].jsProcess.disabled = false;
document.forms["Sales"].lic_disagree.checked = false;
document.forms["Sales"].lic_agree.checked = true;
return (true)
}

function disableSubmit(){
if (document.forms["Sales"].lic_agree.checked = false) {
document.forms["Sales"].jsProcess.enabled = false;
document.forms["Sales"].lic_agree.checked = false;
document.forms["Sales"].lic_disagree.checked = true;
}
return (true)
}

function processCard(){
var GoTo="RW24U_Order.asp" ;
var bOK
var uPass
var RenewalCode=document.forms["Sales"].RenewalCode.value
bOK = "true"

if (RenewalCode.length > 0){
var GoTo="RW24U_Order.asp?RenewalCode=" + document.forms["Sales"].RenewalCode.value;
}else{
if (bOK == "true" && !isEmpty(document.forms["Sales"].uPassword.value)){
if (document.forms["Sales"].uPassword.value !== document.forms["Sales"].uPassword.value){
alert("Entered passwords do not match. Please re-enter your choice.");
document.forms["Sales"].uPassword.focus();
bOK = "false";
}

if (bOK == "true"){
uPass = document.forms["Sales"].uPassword.value
if (uPass.length < 8 || uPass.length > 25){
alert("Your password does not match the length requirement. Please enter another choice.");
document.forms["Sales"].uPassword.focus();
bOK = "false";
}
}
if (bOK == "true"){
var reg = /[a-z]/g;
var reg1 = /[A-Z]/g;
var reg2 = /[0-9]/g;
var b0 = reg.test(uPass);
var b1 = reg1.test(uPass);
var b2 = reg2.test(uPass);
if ((b0 && b1) || (b0 && b2) || (b1 && b2)){
bOK == "true";
}else{
alert("Your password does not match the complexity requirement. Please enter another choice which includes upper case and lower case letters and numbers (e.g. RxX3nUrev).");
document.forms["Sales"].uPassword.focus();
bOK = "false";
}
}
}
}

if (bOK == "true" && (!check_name(document.forms["Sales"].bname.value))){
alert("Please enter your name for billing.");
document.forms["Sales"].bname.focus();
bOK = "false";
}
if (bOK == "true" && (!check_name(document.forms["Sales"].baddr1.value))){
alert("Please enter your address for billing.");
document.forms["Sales"].baddr1.focus();
bOK = "false";
}
if (bOK == "true" && (!check_name(document.forms["Sales"].bcity.value))){
alert("Please enter your city for billing.");
document.forms["Sales"].bcity.focus();
bOK = "false";
}
if (bOK == "true" && (!check_name(document.forms["Sales"].bzip.value))){
alert("Please enter your zip code for billing.");
document.forms["Sales"].bzip.focus();
bOK = "false";
}

if (RenewalCode.length == 0){ 
if (bOK == "true" && ((isEmpty(document.forms["Sales"].bemail.value)) || (emailCheck(document.forms["Sales"].bemail.value).length > 1))){
alert("The email address entered field is empty or does not appear to be correctly formatted.");
document.forms["Sales"].bzip.focus();
bOK = "false";
}
}

if (bOK == "true" && (isEmpty(document.forms["Sales"].bphone.value))){
alert("Please enter a telephone where we may contact you.");
document.forms["Sales"].bphone.focus();
bOK = "false";
}

if (bOK == "true" && (document.forms["Sales"].noSecondAddr.checked)){
document.forms["Sales"].sname.value = document.forms["Sales"].bname.value ;
document.forms["Sales"].saddr1.value = document.forms["Sales"].baddr1.value ;
document.forms["Sales"].saddr2.value = document.forms["Sales"].baddr2.value ;
document.forms["Sales"].scity.value = document.forms["Sales"].bcity.value ;
document.forms["Sales"].sstate.value = document.forms["Sales"].bstate.value ;
document.forms["Sales"].szip.value = document.forms["Sales"].bzip.value ;
document.forms["Sales"].scountry.value = document.forms["Sales"].bcountry.value ;
}else{
if (bOK == "true" && (!check_name(document.forms["Sales"].sname.value))){
alert("Please enter your name for shipping.");
document.forms["Sales"].sname.focus();
bOK = "false";
}
if (bOK == "true" && (!check_name(document.forms["Sales"].saddr1.value))){
alert("Please enter your address for shipping.");
document.forms["Sales"].saddr1.focus();
bOK = "false";
}
if (bOK == "true" && (!check_name(document.forms["Sales"].scity.value))){
alert("Please enter your city for shipping.");
document.forms["Sales"].scity.focus();
bOK = "false";
}
if (bOK == "true" && (!check_name(document.forms["Sales"].szip.value))){
alert("Please enter your zip code for shipping.");
document.forms["Sales"].szip.focus();
bOK = "false";
}
}

if (bOK == "true" && (isEmpty(document.forms["Sales"].cardnumber.value))){
alert("Please enter a credit card number.");
document.forms["Sales"].cardnumber.focus();
bOK = "false";
}else{
if (bOK == "true" && (!validateCreditCard(document.forms["Sales"].cardnumber.value))){
alert("This does not appear to be a valid credit card number, please re-enter the number.");
document.forms["Sales"].cardnumber.focus();
bOK = "false";
}
}

if (bOK == "true" && (!check_numbers(document.forms["Sales"].cvmvalue.value))){
alert("The CVM number does not appear to be valid. Please check the code found on the back of your card.");
document.forms["Sales"].cvmvalue.focus();
bOK = "false";
}

if ( bOK == "true" ){
//alert("Product Cost: " + "<%=ProductCost%>")
document.forms["Sales"].aspProcess.value = "GoForth"
//document.forms["Sales"].charged.value = "<%=Session('ProductCost')%>"
//if  (document.forms["Sales"].review_agree.checked) {
document.forms["Sales"].canReview.value = "false"
//}
document.forms["Sales"].action=GoTo;
document.forms["Sales"].submit();
}
}

function calcTotal(val){
var totalPrice
totalPrice = parseInt(val) * parseInt("<%=ProductCost%>");
//alert(format(totalPrice,2));
document.forms["Sales"].total.value = format(totalPrice,2);
//document.forms["Sales"].subtotal.disabled = false;
document.forms["Sales"].subtotal.value = format(totalPrice,2);
document.forms["Sales"].charged.value = format(totalPrice,2);
//document.forms["Sales"].subtotal.disabled = true;
}

function format(expr, decplaces){
 var str = "" + Math.round(eval(expr) * Math.pow(10,decplaces))
 while (str.length <= decplaces) {
  str = "0" + str;
  }
  var decpoint = str.length - decplaces
  return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}

// Credit Card Validation Javascript
// copyright 12th May 2003, by Stephen Chapman, Felgall Pty Ltd

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.

function validateCreditCard(s) {
// remove non-numerics
var v = "0123456789";
var w = "";
for (i=0; i < s.length; i++) {
x = s.charAt(i);
if (v.indexOf(x,0) != -1)
w += x;
}
// validate number
j = w.length / 2;
if (j < 6.5 || j > 8 || j == 7) return false;
k = Math.floor(j);
m = Math.ceil(j) - k;
c = 0;
for (i=0; i<k; i++) {
a = w.charAt(i*2+m) * 2;
c += a > 9 ? Math.floor(a/10 + a%10) : a;
}
for (i=0; i<k+m; i++) c += w.charAt(i*2+1-m) * 1;
return (c%10 == 0);
}

function emailCheck (emailStr) {

var str = "";
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address.
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")

/* figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	str = "Email address seems incorrect (check @ and .'s)"
	return str;
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid
if (user.match(userPat)==null) {
    // user is not valid
    str = "The Email username doesn't seem to be valid."
    return str;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        str = "Destination IP address is invalid!"
		return str;
	    }
    }
    return str;
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	str = "The Email address domain name doesn't seem to be valid."
    return str;
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 ||
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   str = "The Email address must end in a three-letter domain, or two letter country."
   return str;
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This Email address is missing a hostname!"
   str = errStr
   return str;
}

// Got this far, everything's valid!
return str;
}

function passOK(str)
{
	// five to eleven alpha numeric characters
	var re = /^[A-Za-z0-9]{5,11}$/;
	var bTest = false;
	if (testRegEx(re, str)){
		bTest = true;
		}
	else {
		bTest = false;
                }
	return bTest;
}

function testRegEx(re, str){
   var bTest = false;
   // Test string for existence of regular expression.
   if (re.test(str)){
      bTest = true;
      }
   else
   {   bTest = false;
    }
   return bTest;

}
 //  -->
