

	    // Regular Expressions
	    
	    // zip code validation		
	    reZipCode = /^(\d{5})[\.\-\/ ]?(\d{4})?$/
	    
	    // phone validation		
	    rePhone = /^(\d{3})[\.\-\/ ]?(\d{3})[\.\-\/ ]?(\d{4})$/
	    
	    // email validation
	    reEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/
	    
	    // credit card validation
	    reCCExpiration = /^(\d{2})[\/](\d{4})$/

	    // iContact checkout submit
	    function iContactSignup() {

	        if (trimAll(document.checkout.firstName.value) == "") {
	            document.getElementById("iContactSignupCheckbox").checked = false; 
	            alert("The bill-to first name isn't valid");
	            document.checkout.firstName.focus();
	            document.checkout.firstName.select();
	            return false;}
	            else {
	                var iContactCustFirstName = document.checkout.firstName.value;
	        }

	        if (trimAll(document.checkout.lastName.value) == "") {
	            document.getElementById("iContactSignupCheckbox").checked = false; 
	            alert("The bill-to last name isn't valid");
	            document.checkout.lastName.focus();
	            document.checkout.lastName.select();
	            return false;
	        }
	        else {
	            var iContactCustLastName = document.checkout.lastName.value;
	        }
	        

	        if (reEmail.test(document.checkout.email.value)) {
	            var iContactCustEmail = document.checkout.email.value;
	        }
	        else {
	            document.getElementById("iContactSignupCheckbox").checked = false; 
	            alert("The bill-to email address isn't valid.  Please use the following format: john@company.com")
	            window.document.checkout.email.focus()
	            window.document.checkout.email.select();
	            return false;
	        }

	        var PageWindowString = "iContactPost.asp?iContactCustEmail=" + iContactCustEmail + "&iContactCustFirstName=" + iContactCustFirstName + "&iContactCustLastName=" + iContactCustLastName

	        PageWindow(PageWindowString, '500', '250')
	        
	    }

	    // uncheck the Ship to Same as check box
	    function UncheckShipToSameAs() { 
	      document.getElementById("cbShipToSameAs").checked = false;    
	    }

	    // toggle div display
	    function ToggleDivDisplay(DivID,DivIDImageToggle) {

	        if (document.getElementById(DivID).style.display == "none") {
	            document.getElementById(DivID).style.display = "block";
	            document.getElementById(DivIDImageToggle).src = "CartGenie/Images/toggled.gif";
	        }
	        else {
	            document.getElementById(DivID).style.display = "none";
	            document.getElementById(DivIDImageToggle).src = "CartGenie/Images/toggle.gif";
	        }
	    
	    }

	    // Format number as currency
	    function formatCurrency(num) {
	        num = isNaN(num) || num === '' || num === null ? 0.00 : num;
	        return "$" + parseFloat(num).toFixed(2);
	    }


	    // Set shipping amount on cart page
	    function SetShipAmount(strShippingCharge) {

	        var strOrderSubTotal = opener.document.getElementById('txtOrderSubTotal').value;
	        var dblOrderSubTotal = strOrderSubTotal.replace("$", "");

	        var strPromoAmount = opener.document.getElementById('txtPromoAmount').value;
	        var dblPromoAmount = strPromoAmount.replace("$", "");
	        var dblPromoAmount = dblPromoAmount.replace("(", "");
	        var dblPromoAmount = dblPromoAmount.replace(")", "");
	        
	        var dblShippingCharge = strShippingCharge.replace("$", "");

	        var dblGrandTotalAmount = parseFloat(dblOrderSubTotal) - parseFloat(dblPromoAmount) + (parseFloat(dblShippingCharge));

	        opener.document.getElementById('txtShippingAmount').value = formatCurrency(dblShippingCharge);
	        opener.document.getElementById('txtGrandTotalAmount').value = formatCurrency(dblGrandTotalAmount);

	        window.close();

	    }

	    // Validate credit card number with Mod10
	    function Mod10(ccNumb) {  // v2.0
	        var valid = "0123456789"  // Valid digits in a credit card number
	        var len = ccNumb.length;  // The length of the submitted cc number
	        var iCCN = parseInt(ccNumb);  // integer of ccNumb
	        var sCCN = ccNumb.toString();  // string of ccNumb
	        sCCN = sCCN.replace(/^s+|s+$/g, '');  // strip spaces
	        var iTotal = 0;  // integer total set at zero
	        var bNum = true;  // by default assume it is a number
	        var bResult = false;  // by default assume it is NOT a valid cc
	        var temp;  // temp variable for parsing string
	        var calc;  // used for calculation of each digit

	        // Determine if the ccNumb is in fact all numbers
	        for (var j = 0; j < len; j++) {
	            temp = "" + sCCN.substring(j, j + 1);
	            if (valid.indexOf(temp) == "-1") { bNum = false; }
	        }

	        // if it is NOT a number, you can either alert to the fact, or just pass a failure
	        if (!bNum) {
	            /*alert("Not a Number");*/bResult = false;
	        }

	        // Determine if it is the proper length 
	        if ((len == 0) && (bResult)) {  // nothing, field is blank AND passed above # check
	            bResult = false;
	        } else {  // ccNumb is a number and the proper length - let's see if it is a valid card number
	            if (len >= 15) {  // 15 or 16 for Amex or V/MC
	                for (var i = len; i > 0; i--) {  // LOOP throught the digits of the card
	                    calc = parseInt(iCCN) % 10;  // right most digit
	                    calc = parseInt(calc);  // assure it is an integer
	                    iTotal += calc;  // running total of the card number as we loop - Do Nothing to first digit
	                    i--;  // decrement the count - move to the next digit in the card
	                    iCCN = iCCN / 10;                               // subtracts right most digit from ccNumb
	                    calc = parseInt(iCCN) % 10;    // NEXT right most digit
	                    calc = calc * 2;                                 // multiply the digit by two
	                    // Instead of some screwy method of converting 16 to a string and then parsing 1 and 6 and then adding them to make 7,
	                    // I use a simple switch statement to change the value of calc2 to 7 if 16 is the multiple.
	                    switch (calc) {
	                        case 10: calc = 1; break;       //5*2=10 & 1+0 = 1
	                        case 12: calc = 3; break;       //6*2=12 & 1+2 = 3
	                        case 14: calc = 5; break;       //7*2=14 & 1+4 = 5
	                        case 16: calc = 7; break;       //8*2=16 & 1+6 = 7
	                        case 18: calc = 9; break;       //9*2=18 & 1+8 = 9
	                        default: calc = calc;           //4*2= 8 &   8 = 8  -same for all lower numbers
	                    }
	                    iCCN = iCCN / 10;  // subtracts right most digit from ccNum
	                    iTotal += calc;  // running total of the card number as we loop
	                }  // END OF LOOP
	                if ((iTotal % 10) == 0) {  // check to see if the sum Mod 10 is zero
	                    bResult = true;  // This IS (or could be) a valid credit card number.
	                } else {
	                    bResult = false;  // This could NOT be a valid credit card number
	                }
	            }
	        }

	        return bResult; // Return the results
	    }

	    //hide processing images
	    function CCProcessingImage() {
	        document.getElementById("CreditCardProcessingImage").style.display = "none";
	    }

	    //enable order review button
	    function EnableObject(ObjectId, BooleanValue, GoToObject) {
	        if (BooleanValue == 'true') {
	            document.getElementById(ObjectId).disabled = false;
	            if (GoToObject == 'true') {
	                document.getElementById(ObjectId).focus();
	            }
	        }
	        else {
	            document.getElementById(ObjectId).disabled = true;
	        }
	    }

	    // Validate Wish List Qty and submit
	    function ValidateWishListQty(ValidationValue, Action, FormName) {

	        if (ValidateOrderQty(ValidationValue) == false) {
	            return false;
	        }
	        else {
	            SetActionSubmit(Action, FormName)
	        }

	    }

	    // Validate order qty is not less than minimum order qty
	    function ValidateExpressQty(ValidationValue, MOQ) {

	        if (ValidateOrderQty(ValidationValue) == false) {
	            document.getElementById(ValidationValue).value = MOQ;
	            document.getElementById(ValidationValue).focus();
	            document.getElementById(ValidationValue).select();
	            return false;
	        }

	    }

	    //validate length
	    function ValidateStrLength(StrValue, MinRequiredLength, MaxRequiredLength) {
	        if (StrValue.length >= MinRequiredLength && StrValue.length <= MaxRequiredLength) {
	            return true;
	        }
	        else {
	            return false;
	        }
	    }

	    //validate alphanumeric or one of the following !,#,$,&,@
	    function AlphaNumeric(numaric) {
	        for (var j = 0; j < numaric.length; j++) {
	            var alphaa = numaric.charAt(j);
	            var hh = alphaa.charCodeAt(0);
	            if ((hh == 33) || (hh == 35) || (hh == 36) || (hh == 38) || (hh == 64) || (hh > 47 && hh < 58) || (hh > 65 && hh < 91) || (hh > 96 && hh < 123))
	            { }
	            else {
	                return false;
	            }
	        }
	        return true;
	    }

	    // Changes the cursor to a hand
	    function cursor_hand() {
	        document.body.style.cursor = 'pointer';
	    }

	    // Changes the cursor to an hourglass
	    function cursor_wait() {
	        document.body.style.cursor = 'wait';
	    }

	    // Returns the cursor to the default pointer
	    function cursor_clear() {
	        document.body.style.cursor = 'default';
	    }

	    //show-hide ship-to
	    function ShowHideShipTo(Action) {
	        if (Action == "true") {
	            document.getElementById("ShipToDisplayFlag").value = "0";
	            document.getElementById("ShipToHeaderPadding").style.display = 'none';
	            document.getElementById("ShipToHeaderLabel").style.display = 'none';
	            document.getElementById("ShipToHeaderText").style.display = 'none';
	            document.getElementById("ShipCopyBillTo").style.display = 'none';
	            document.getElementById("FirstNameShip").style.display = 'none';
	            document.getElementById("LastNameShip").style.display = 'none';
	            document.getElementById("CompanyShip").style.display = 'none';
	            document.getElementById("StreetShip").style.display = 'none';
	            document.getElementById("Street2Ship").style.display = 'none';
	            document.getElementById("Street3Ship").style.display = 'none';
	            document.getElementById("CityShip").style.display = 'none';
	            document.getElementById("CountryShip").style.display = 'none';
	            document.getElementById("ShipState").style.display = 'none';
	            document.getElementById("ZipShip").style.display = 'none';
	            document.getElementById("PhoneShip").style.display = 'none';
	            document.getElementById("EmailShip").style.display = 'none';
	            document.getElementById("ShipToLocType").style.display = 'none';
	            document.getElementById("AddressBook").style.display = 'none';
	        }
	        else {
	            document.getElementById("ShipToDisplayFlag").value = "1";
	            document.getElementById("ShipToHeaderPadding").style.display = 'block';
	            document.getElementById("ShipToHeaderLabel").style.display = 'block';
	            document.getElementById("ShipToHeaderText").style.display = 'block';
	            document.getElementById("ShipCopyBillTo").style.display = 'block';
	            document.getElementById("FirstNameShip").style.display = 'block';
	            document.getElementById("LastNameShip").style.display = 'block';
	            document.getElementById("CompanyShip").style.display = 'block';
	            document.getElementById("StreetShip").style.display = 'block';
	            document.getElementById("Street2Ship").style.display = 'block';
	            document.getElementById("Street3Ship").style.display = 'block';
	            document.getElementById("CityShip").style.display = 'block';
	            document.getElementById("CountryShip").style.display = 'block';
	            document.getElementById("ShipState").style.display = 'block';
	            document.getElementById("ZipShip").style.display = 'block';
	            document.getElementById("PhoneShip").style.display = 'block';
	            document.getElementById("EmailShip").style.display = 'block';
	            document.getElementById("ShipToLocType").style.display = 'block';
	            document.getElementById("AddressBook").style.display = 'block';
	        }
	    }

	    //clear cookies
	    function cookieClear() {
	        var cookie = document.cookie.split(/;\s*/);
	        for (var i = 0; i < cookie.length; i++) {
	            var cName = cookie[i].split('=')[0];
	            document.cookie = cName + "=; path=/; expires=Thu, 01-Jan-1970 00:00:01 GMT;";
	            document.cookie = cName + "=; expires=Thu, 01-Jan-1970 00:00:01 GMT;";
	        }
	    }

	    //validate session timeout
	    function SessionTimeout(TimeoutTime, Message, RedirectOkURL, RedirectCancelURL) {
	        setTimeout("ConfirmRedirect('" + Message + "','" + RedirectOkURL + "','" + RedirectCancelURL + "')", TimeoutTime)
	    }

	    //confirm response and redirect
	    function ConfirmRedirect(Message, RedirectOkURL, RedirectCancelURL) {
	        var response = confirm(Message)

	        if (response == true) {  //user pressed OK
	            location.href = RedirectOkURL
	        }
	        else {  //user pressed Cancel
	            location.href = RedirectCancelURL
	        }
	    }

	    //validate gift card email address
	    function ValidateGiftCardOrder() {

	        //get the recipient id
	        var RecipientToId = document.getElementById("RecipientTo").value
	        var RecipientFromId = document.getElementById("RecipientFrom").value
	        var RecipientEmailId = document.getElementById("RecipientEmail").value
	        var RecipientEmailConfirmId = document.getElementById("RecipientEmailConfirm").value

	        //validate the To field 
	        var RecipientTo = document.getElementById(RecipientToId).value

	        if (RecipientTo == "") {
	            alert("The To field is required");
	            document.getElementById(RecipientToId).focus()
	            document.getElementById(RecipientToId).select()
	            return false
	        }

	        //validate the From field 
	        var RecipientFrom = document.getElementById(RecipientFromId).value

	        if (RecipientFrom == "") {
	            alert("The From field is required");
	            document.getElementById(RecipientFromId).focus();
	            document.getElementById(RecipientFromId).select();
	            return false;
	        }

	        //validate the recipient email

	        var RecipientEmail = document.getElementById(RecipientEmailId).value.toUpperCase()

	        if (reEmail.test(RecipientEmail)) {
	        } // The email is valid 
	        else {
	            alert("The Recipient Email address isn't valid.  Please use the following format: john@company.com")
	            document.getElementById(RecipientEmailId).focus();
	            document.getElementById(RecipientEmailId).select();
	            return false;
	        }

	        //validate the confirm email

	        var RecipientEmailConfirm = document.getElementById(RecipientEmailConfirmId).value.toUpperCase()

	        if (RecipientEmailConfirm == "") {
	            alert("The Confirm Email field is required");
	            document.getElementById(RecipientEmailConfirmId).focus();
	            document.getElementById(RecipientEmailConfirmId).select();
	            return false;
	        }

	        //validate the email addresses match 

	        if (RecipientEmail != RecipientEmailConfirm) {
	            alert("The email addresses must match");
	            document.getElementById(RecipientEmailConfirmId).focus();
	            document.getElementById(RecipientEmailConfirmId).select();
	            return false;
	        }

	    }

	    //validation function for iContact.com
	    function verifyRequired(First_Name_Required, Last_Name_Required, Prefix_Required, Suffix_Required, Fax_Required, Phone_Required, Business_Required, Address_1_Required, City_Required, State_Required, Zip_Required) {
	        if (document.icpsignup.fields_email.value == "" || document.icpsignup.fields_email.value == "Email") {
	            alert("The Email field is required.");
	            return false;
	        }

	        if (First_Name_Required == "Yes") {
	            if (document.icpsignup.fields_fname.value == "" || document.icpsignup.fields_fname.value == "First Name") {
	                alert("The First Name field is required.");
	                return false;
	            }
	        }

	        if (Last_Name_Required == "Yes") {
	            if (document.icpsignup.fields_lname.value == "" || document.icpsignup.fields_lname.value == "Last Name") {
	                alert("The Last Name field is required.");
	                return false;
	            }
	        }

	        if (Prefix_Required == "Yes") {
	            if (document.icpsignup.fields_prefix.value == "" || document.icpsignup.fields_prefix.value == "Prefix") {
	                alert("The Prefix field is required.");
	                return false;
	            }
	        }

	        if (Suffix_Required == "Yes") {
	            if (document.icpsignup.fields_suffix.value == "" || document.icpsignup.fields_suffix.value == "Suffix") {
	                alert("The Suffix field is required.");
	                return false;
	            }
	        }

	        if (Fax_Required == "Yes") {
	            if (document.icpsignup.fields_fax.value == "" || document.icpsignup.fields_fax.value == "Fax Number") {
	                alert("The Fax Number field is required.");
	                return false;
	            }
	        }

	        if (Phone_Required == "Yes") {
	            if (document.icpsignup.fields_phone.value == "" || document.icpsignup.fields_phone.value == "Phone Number") {
	                alert("The Phone Number field is required.");
	                return false;
	            }
	        }

	        if (Business_Required == "Yes") {
	            if (document.icpsignup.fields_business.value == "" || document.icpsignup.fields_business.value == "Company") {
	                alert("The Company field is required.");
	                return false;
	            }
	        }

	        if (Address_1_Required == "Yes") {
	            if (document.icpsignup.fields_address1.value == "" || document.icpsignup.fields_address1.value == "Address 1") {
	                alert("The Address 1 field is required.");
	                return false;
	            }
	        }

	        if (City_Required == "Yes") {
	            if (document.icpsignup.fields_city.value == "" || document.icpsignup.fields_city.value == "City") {
	                alert("The City field is required.");
	                return false;
	            }
	        }

	        if (State_Required == "Yes") {
	            if (document.icpsignup.fields_state.value == "" || document.icpsignup.fields_state.value == "State/Province") {
	                alert("The State/Province field is required.");
	                return false;
	            }
	        }

	        if (Zip_Required == "Yes") {
	            if (document.icpsignup.fields_zip.value == "" || document.icpsignup.fields_zip.value == "Postal Code") {
	                alert("The Postal Code field is required.");
	                return false;
	            }
	        }

	        return true;
	    }

	    //validate check for express ordering
	    var checkflag = "false";

	    function check(field) {
	        if (checkflag == "false") {
	            for (i = 0; i < field.length; i++) {
	                field[i].checked = true;
	            }
	            checkflag = "true";
	            return "Uncheck";
	        }
	        else {
	            for (i = 0; i < field.length; i++) {
	                field[i].checked = false;
	            }
	            checkflag = "false";
	            return "Check All";
	        }
	    }

	    //validate string is not empty by trimming left and right
	    function trimAll(sString) {
	        while (sString.substring(0, 1) == ' ') {// trim the left side of string
	            sString = sString.substring(1, sString.length);
	        }
	        while (sString.substring(sString.length - 1, sString.length) == ' ') {// trim the right side of string
	            sString = sString.substring(0, sString.length - 1);
	        }
	        return sString;
	    }

	    //validate login page
	    function PaymentMethodValidation(PaymentGateway, TestFlag, OrderAmount) {
	        // set the action for the form

	        //handle No Charge    
	        if (OrderAmount == "0") {
	            document.form1.action = "Checkout3a.asp";
	            document.form1.submit()
	        }

	        //handle credit cards 
	        if (OrderAmount > "0") {
	            if (document.getElementById("payMethod0DisplayFlag").value == "1") {
	                if (document.getElementById("payMethod0").checked) {

	                    // Validate credit card name
	                    if (document.form1.ccname.value == "") {
	                        alert("The cardholder name isn't valid");
	                        document.form1.ccname.focus();
	                        document.form1.ccname.select();
	                        return false
	                    }

	                    // Validate credit card number
	                    if (document.form1.ccnumber.value == "") {
	                        alert("The credit card number isn't valid");
	                        document.form1.ccnumber.focus();
	                        document.form1.ccnumber.select();
	                        return false
	                    }

	                    // Validate credit card number is numeric
	                    if (IsNumericCreditCard(document.form1.ccnumber.value) == false) {
	                        alert("The credit card number must be numeric and cannot contain dashes or spaces");
	                        document.form1.ccnumber.focus();
	                        document.form1.ccnumber.select();
	                        return false
	                    }

	                    // Validate credit card length is 16 digits: Visa 
	                    if (document.getElementById("ccDisplayVisa").value == "true" && document.getElementById("ccTypeVisa").checked) {
	                        if (ValidateStrLength(document.form1.ccnumber.value, 16, 16) == false) {
	                            alert("The Visa credit card number must be 16 digits long");
	                            document.form1.ccnumber.focus();
	                            document.form1.ccnumber.select();
	                            return false
	                        }
	                    }

	                    // Validate Visa credit card begins with 4
	                    if (document.getElementById("ccDisplayVisa").value == "true" && document.getElementById("ccTypeVisa").checked) {
	                        if (document.form1.ccnumber.value.substring(0, 1) != 4) {
	                            alert("The Visa credit card number must begin with a 4");
	                            document.form1.ccnumber.focus();
	                            document.form1.ccnumber.select();
	                            return false
	                        }
	                    }

	                    // Validate Visa credit card passes MOD 10
	                    if (PaymentGateway == "NONE" && TestFlag == "FALSE") {
	                        if (document.getElementById("ccDisplayVisa").value == "true" && document.getElementById("ccTypeVisa").checked) {
	                            //test mod 10
	                            var Mod10Check = Mod10(document.form1.ccnumber.value)
	                            if (Mod10Check == false) {
	                                alert("The Visa credit card number is not valid.  Please enter a valid credit card number.");
	                                document.form1.ccnumber.focus();
	                                document.form1.ccnumber.select();
	                                return false

	                            }
	                        }
	                    }

	                    // Validate credit card length is 16 digits: MC 
	                    if (document.getElementById("ccDisplayMC").value == "true" && document.getElementById("ccTypeMC").checked) {
	                        if (ValidateStrLength(document.form1.ccnumber.value, 16, 16) == false) {
	                            alert("The Mastercard credit card number must be 16 digits long");
	                            document.form1.ccnumber.focus();
	                            document.form1.ccnumber.select();
	                            return false
	                        }
	                    }

	                    // Validate Mastercard credit card begins with 5
	                    if (document.getElementById("ccDisplayMC").value == "true" && document.getElementById("ccTypeMC").checked) {
	                        if (document.form1.ccnumber.value.substring(0, 2) != 51 && document.form1.ccnumber.value.substring(0, 2) != 52 && document.form1.ccnumber.value.substring(0, 2) != 53 && document.form1.ccnumber.value.substring(0, 2) != 54 && document.form1.ccnumber.value.substring(0, 2) != 55) {
	                            alert("The Mastercard credit card number must begin with one of the following: 51,52,53,54,55");
	                            document.form1.ccnumber.focus();
	                            document.form1.ccnumber.select();
	                            return false
	                        }
	                    }


	                    // Validate MC credit card passes MOD 10
	                    if (PaymentGateway == "NONE" && TestFlag == "FALSE") {
	                        if (document.getElementById("ccDisplayMC").value == "true" && document.getElementById("ccTypeMC").checked) {
	                            //test mod 10
	                            var Mod10Check = Mod10(document.form1.ccnumber.value)
	                            if (Mod10Check == false) {
	                                alert("The Mastercard credit card number is not valid.  Please enter a valid credit card number.");
	                                document.form1.ccnumber.focus();
	                                document.form1.ccnumber.select();
	                                return false

	                            }
	                        }
	                    }

	                    // Validate credit card length is 15 digits: Amex
	                    if (document.getElementById("ccDisplayAmex").value == "true" && document.getElementById("ccTypeAmex").checked) {
	                        if (ValidateStrLength(document.form1.ccnumber.value, 15, 15) == false) {
	                            alert("American Express credit card numbers must be 15 digits long");
	                            document.form1.ccnumber.focus();
	                            document.form1.ccnumber.select();
	                            return false
	                        }
	                    }


	                    // Validate Amex credit card begins with 3
	                    if (document.getElementById("ccDisplayAmex").value == "true" && document.getElementById("ccTypeAmex").checked) {
	                        if (document.form1.ccnumber.value.substring(0, 2) != 34 && document.form1.ccnumber.value.substring(0, 2) != 37) {
	                            alert("The American Express credit card number must begin with a 34 or 37");
	                            document.form1.ccnumber.focus();
	                            document.form1.ccnumber.select();
	                            return false
	                        }
	                    }

	                    // Validate AMEX credit card passes MOD 10
	                    if (PaymentGateway == "NONE" && TestFlag == "FALSE") {
	                        if (document.getElementById("ccDisplayAmex").value == "true" && document.getElementById("ccTypeAmex").checked) {
	                            //test mod 10
	                            var Mod10Check = Mod10(document.form1.ccnumber.value)
	                            if (Mod10Check == false) {
	                                alert("The American Express credit card number is not valid.  Please enter a valid credit card number.");
	                                document.form1.ccnumber.focus();
	                                document.form1.ccnumber.select();
	                                return false

	                            }
	                        }
	                    }

	                    // Validate credit card length is 16 digits: Discover, 
	                    if (document.getElementById("ccDisplayDiscover").value == "true" && document.getElementById("ccTypeDiscover").checked) {
	                        if (ValidateStrLength(document.form1.ccnumber.value, 16, 16) == false) {
	                            alert("The Discover credit card number must be 16 digits long");
	                            document.form1.ccnumber.focus();
	                            document.form1.ccnumber.select();
	                            return false
	                        }
	                    }

	                    // Validate Discover credit card begins with 6
	                    if (document.getElementById("ccDisplayDiscover").value == "true" && document.getElementById("ccTypeDiscover").checked) {
	                        if (document.form1.ccnumber.value.substring(0, 4) != 6011) {
	                            alert("The Discover credit card number must begin with a 6011");
	                            document.form1.ccnumber.focus();
	                            document.form1.ccnumber.select();
	                            return false
	                        }
	                    }

	                    // Validate Discover credit card passes MOD 10
	                    if (PaymentGateway == "NONE" && TestFlag == "FALSE") {
	                        if (document.getElementById("ccDisplayDiscover").value == "true" && document.getElementById("ccTypeDiscover").checked) {
	                            //test mod 10
	                            var Mod10Check = Mod10(document.form1.ccnumber.value)
	                            if (Mod10Check == false) {
	                                alert("The Discover credit card number is not valid.  Please enter a valid credit card number.");
	                                document.form1.ccnumber.focus();
	                                document.form1.ccnumber.select();
	                                return false

	                            }
	                        }
	                    }

	                    // Validate credit card expiration month
	                    if (document.form1.expMonth.value == "") {
	                        alert("The credit card expiration month isn't valid");
	                        document.form1.expMonth.focus();
	                        return false
	                    }

	                    // Validate credit card expiration year
	                    if (document.form1.expYear.value == "") {
	                        alert("The credit card expiration year isn't valid");
	                        document.form1.expYear.focus();
	                        return false
	                    }

	                    // Validate credit card id
	                    if (document.form1.ccnumberId.value == "") {
	                        alert("The credit card id isn't valid");
	                        document.form1.ccnumberId.focus();
	                        document.form1.ccnumberId.select();
	                        return false
	                    }

	                    // Set action
	                    if (PaymentGateway == "NONE") {
	                        document.form1.action = "Checkout3a.asp";
	                    }

	                    if (PaymentGateway == "AUTHORIZE.NET") {
	                        document.form1.action = "Checkout3a.asp";
	                    }

	                    if (PaymentGateway == "IGS") {
	                        document.form1.action = "Checkout3a.asp";
	                    }

	                    if (PaymentGateway == "Moneris") {
	                        document.form1.action = "Checkout3a.asp";
	                    }

	                    if (PaymentGateway == "iTransact") {
	                        document.form1.action = "Checkout3a.asp";
	                    }

	                    if (PaymentGateway == "SecurePay") {
	                        document.form1.action = "Checkout3a.asp";
	                    }

	                    if (PaymentGateway == "Moneris-US") {
	                        document.form1.action = "Checkout3a.asp";
	                    }

	                    if (PaymentGateway == "Moneris-CA") {
	                        document.form1.action = "Checkout3a.asp";
	                    }

	                    if (PaymentGateway == "VeriSign_PL") {
	                        document.form1.action = "https://payments.verisign.com/payflowlink";
	                    }
	                }
	            }

	            //handle business Account  
	            if (document.getElementById("payMethod1DisplayFlag").value == "1") {
	                if (document.getElementById("payMethod1").checked) {
	                    document.form1.action = "Checkout3a.asp";
	                }
	            }

	            //handle PayPal    
	            if (document.getElementById("payMethod2DisplayFlag").value == "1") {
	                if (document.getElementById("payMethod2").checked) {
	                    document.form1.action = "https://www.paypal.com/cgi-bin/webscr";
	                }
	            }

	            //handle internal account 
	            if (document.getElementById("CreditCardFlag").value == "0") {
	                if (document.getElementById("payMethod3").checked) {
	                    document.form1.action = "Checkout3a.asp";
	                }
	            }

	            //handle In-Store/Will Call    
	            if (document.getElementById("payMethod4DisplayFlag").value == "1") {
	                if (document.getElementById("payMethod4").checked) {
	                    document.form1.action = "Checkout3a.asp";
	                }
	            }

	            //handle Check/Money Order   
	            if (document.getElementById("payMethod5DisplayFlag").value == "1") {
	                if (document.getElementById("payMethod5").checked) {
	                    document.form1.action = "Checkout3a.asp";
	                }
	            }

	            //handle C.O.D.   
	            if (document.getElementById("payMethod6DisplayFlag").value == "1") {
	                if (document.getElementById("payMethod6").checked) {
	                    document.form1.action = "Checkout3a.asp";
	                }
	            }

	            //handle Phone/Fax  
	            if (document.getElementById("payMethod7DisplayFlag").value == "1") {
	                if (document.getElementById("payMethod7").checked) {
	                    document.form1.action = "Checkout3a.asp";
	                }
	            }

	            //handle Cash  
	            if (document.getElementById("payMethod10DisplayFlag").value == "1") {
	                if (document.getElementById("payMethod10").checked) {
	                    document.form1.action = "Checkout3a.asp";
	                }
	            }
	            
	            //handle E-check
	            if (document.getElementById("payMethod8DisplayFlag").value == "1") {
	                if (document.getElementById("payMethod8").checked) {

	                    // Validate Tax ID / SSN Number 
	                    if (document.form1.x_customer_tax_id.value == "") {
	                        alert("The Tax ID or SSN isn't valid");
	                        document.form1.x_customer_tax_id.focus();
	                        document.form1.x_customer_tax_id.select();
	                        return false
	                    }

	                    // Validate Bank Acct Name 
	                    if (document.form1.x_bank_acct_name.value == "") {
	                        alert("The Name on Bank Account isn't valid");
	                        document.form1.x_bank_acct_name.focus();
	                        document.form1.x_bank_acct_name.select();
	                        return false
	                    }

	                    // Validate Bank Name 
	                    if (document.form1.x_bank_name.value == "") {
	                        alert("The Bank Name isn't valid");
	                        document.form1.x_bank_name.focus();
	                        document.form1.x_bank_name.select();
	                        return false
	                    }


	                    // Validate Bank Acct Number 
	                    if (document.form1.x_bank_acct_num.value == "") {
	                        alert("The Bank Account Number isn't valid");
	                        document.form1.x_bank_acct_num.focus();
	                        document.form1.x_bank_acct_num.select();
	                        return false
	                    }


	                    // Validate Bank Aba Code 
	                    if (document.form1.x_bank_aba_code.value == "") {
	                        alert("The Bank ABA/Routing Number isn't valid");
	                        document.form1.x_bank_aba_code.focus();
	                        document.form1.x_bank_aba_code.select();
	                        return false
	                    }

	                    // Set action

	                    if (PaymentGateway == "AUTHORIZE.NET") {
	                        document.form1.action = "Checkout3a.asp";
	                    }
	                }
	            }

	            // Set submit
	            document.form1.submit()
	        }

	    }  // End function

	    //validate login page
	    function FormValidationChk() {

	        // Validate first name has been entered	 	
	        if (document.Form3.ufirstname.value == "") {
	            alert("The first name isn't valid");
	            document.Form3.ufirstname.focus();
	            return false
	        }

	        // Validate last name has been entered	 	
	        if (document.Form3.ulastname.value == "") {
	            alert("The last name isn't valid");
	            document.Form3.ulastname.focus();
	            return false
	        }

	        // Validate user name has been entered	 	
	        if (document.Form3.newusername.value == "") {
	            alert("The username isn't valid");
	            document.Form3.newusername.focus();
	            return false
	        }

	        // Validate password has been entered	 	
	        if (document.Form3.newpassword.value == "") {
	            alert("The password isn't valid");
	            document.Form3.newpassword.focus();
	            return false
	        }

	        // Validate password and confirm password match				
	        if (document.Form3.newpassword.value == document.Form3.confirmPassword.value)
	        { } // value are the same
	        else {
	            alert("The Password and Confirm Password fields must match");
	            document.Form3.newpassword.focus();
	            return false
	        }

	        // Validate password is at least 6 characters	
	        var npwd = trimAll(document.Form3.newpassword.value)
	        var MinRequiredLength = 6
	        var MaxRequiredLength = 20

	        if (ValidateStrLength(npwd, MinRequiredLength, MaxRequiredLength) == true)
	        { } // password length is ok 
	        else {
	            alert("The Password must be between 6 and 20 alphanumeric characters");
	            document.Form3.newpassword.focus();
	            return false
	        }

	        // Validate password is alphanumeric or one of the following !,#,$,&,@	
	        if (AlphaNumeric(npwd) == true)
	        { } // password length is ok 
	        else {
	            alert("The Password must contain alphanumeric characters or any of the following:!,#,$,&,@ ");
	            document.Form3.newpassword.focus();
	            return false
	        }

	        // Validate email has been entered	 	

	        if (reEmail.test(document.Form3.email.value))
	        { } // The email is valid 
	        else {
	            alert("The email address isn't valid.  Please use the following format: john@company.com")
	            document.Form3.email.focus();
	            return false
	        }

	    }  // End function


	    //Personalization Answer Length
	    function CheckAnswerLength(MaxLength, FormElement) {
	        var FormElementLength = document.getElementById(FormElement).value.length

	        if (MaxLength == FormElementLength) {
	            alert("The maximum number of characters is " + MaxLength);
	        }
	    }

	    //Payment Method Ajax handler
	    function AjaxHandlerPaymentMethod(FormElementId, PaymentMethod) {
	        var xmlHttp;
	        try {
	            // Firefox, Opera 8.0+, Safari    
	            xmlHttp = new XMLHttpRequest();
	        }
	        catch (e) {    // Internet Explorer    
	            try
      { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
	            catch (e) {
	                try
        { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
	                catch (e) {
	                    alert("Your browser does not support AJAX!");
	                    return false;
	                }
	            }
	        }
	        xmlHttp.onreadystatechange = function() {
	            if (xmlHttp.readyState == 4) {
	                var response = xmlHttp.responseText;
	                document.getElementById(FormElementId).innerHTML = response;
	            }
	        }

	        //var PM = document.getElementById("payMethod").value  

	        xmlHttp.open("GET", "AjaxHandler.asp?Handler=WritePaymentMethod&PaymentMethod=" + PaymentMethod, true);
	        xmlHttp.send(null);
	    }


	    //General Ajax handler
	    function AjaxHandler(FormElementId, CountryId, HtmlTagName, SelectedState) {
	        var xmlHttp;
	        try {
	            // Firefox, Opera 8.0+, Safari    
	            xmlHttp = new XMLHttpRequest();
	        }
	        catch (e) {    // Internet Explorer    
	            try
      { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
	            catch (e) {
	                try
        { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
	                catch (e) {
	                    alert("Your browser does not support AJAX!");
	                    return false;
	                }
	            }
	        }
	        xmlHttp.onreadystatechange = function() {
	            if (xmlHttp.readyState == 4) {
	                var response = xmlHttp.responseText;
	                document.getElementById(FormElementId).innerHTML = response;
	            }
	        }


	        if (CountryId != 1 && CountryId != 40) {
	            CountryId = 0
	        }

	        xmlHttp.open("GET", "AjaxHandler.asp?Handler=WriteStateList&CountryId=" + CountryId + "&HtmlTagName=" + HtmlTagName + "&SelectedState=" + SelectedState, true);
	        xmlHttp.send(null);
	    }

	    //Set text box to empty
	    function SetTextBoxNull(FocusObject) {
	        document.getElementById(FocusObject).value = "";
	    }

	    //Set text box to default value
	    function SetTextBoxDefault(FocusObject, DefaultValue) {

	        var str = document.getElementById(FocusObject).value

	        if (str.length == "0") {
	            document.getElementById(FocusObject).value = DefaultValue
	        }

	    }

	    //Handle wish list
	    function SetWishListTypeFocus(SetObject, FocusObject) {
	        document.getElementById(SetObject).checked = true;
	        if (FocusObject != "") {
	            document.getElementById(FocusObject).select()
	        }
	        else {
	            document.getElementById("FavoritesGroupName").value = "- Enter New List Name Here -"
	        }
	    }

	    //validate custom form
	    function ValidateCustomForm() {
	        // Validate fields

	        for (i = 1; i < 31; i++) {
	            if (document.getElementById("Field" + i + "_Display").value == "Yes") {
	                if (document.getElementById("Field" + i + "Required").value == "Yes") {
	                    if (document.getElementById("Field" + i + "").value == "") {
	                        alert("The " + document.getElementById("Field" + i + "_Label").value + " field is required.");
	                        document.getElementById("Field" + i + "").focus();
	                        return false
	                    }
	                }
	            }
	        }
	    }

	    //set the form action event
	    function SetActionSubmit(Page, FormName) {
	        eval('document.' + FormName + '.action ="' + Page + '"');
	        eval('document.' + FormName + '.submit()')
	    }

	    //submit form
	    function SubmitForm(FormName) {
	        eval('document.' + FormName + '.submit()')
	    }

	    //adv search set objects
	    function setFields() {

	        document.formAdvSearch.SearchFor.value = ""
	        document.formAdvSearch.bid.value = 0

	        if (document.formAdvSearch.cid.value > 0) {
	            window.location = "search.asp"
	        }
	    }

	    //adv search reload page
	    function reloadSearch() {
	        document.formAdvSearch.action = "search.asp"
	        document.formAdvSearch.submit()
	    }

	    //search submit form validation
	    function valSearch() {

	        if (document.formSearch.SearchFor.value == "") {
	            alert("You must enter a search keyword or phrase");
	            return false
	        }

	        // formSearch.action = "SearchResults.asp"
	        //formSearch.submit()      
	    }

	    //adv search submit form validation
	    function valAdvSearch() {

	        if (document.formAdvSearch.SearchFor.value == "") {
	            alert("You must enter a search keyword or phrase");
	            return false
	        }

	        // formAdvSearch.action = "SearchResults.asp"
	        //  formAdvSearch.submit()      
	    }

	    function disable() {
	        if (event.button == 2 || event.button == 3)
	        { alert("Right click not available.") }
	    }

	    function CompareCounter() {
	        var Records = document.getElementsByName("compareBox")
	        if (Records.length > 0) {
	            var NewCount = 0
	            for (i = 0; i < Records.length; i++) {
	                thisRecord = Records[i]
	                if (thisRecord.checked == true) {
	                    var Count = 1
	                }
	                else {
	                    var Count = 0
	                }
	                var NewCount = (NewCount + Count)
	            }
	            if (NewCount > 3) {
	                alert("Please limit your selection to three products"); return false
	            }
	        }
	    }

	    function ValidateCount() {
	        var Records = document.getElementsByName("compareBox")
	        if (Records.length > 0) {
	            var NewCount = 0
	            for (i = 0; i < Records.length; i++) {
	                thisRecord = Records[i]
	                if (thisRecord.checked == true) {
	                    var Count = 1
	                }
	                else {
	                    var Count = 0
	                }
	                var NewCount = (NewCount + Count)
	            }
	            if (NewCount < 2) {
	                alert("Please select a minimum of two products"); return false
	            }
	            if (NewCount > 3) {
	                alert("Please limit your selection to three products"); return false
	            }
	        }
	    }

	    function FormValidation() {

	        if (document.form1.eName.value == "")
	        { alert("Please provide your name"); return false }

	        if (reEmail.test(document.form1.eAddress.value)) {
	        } // The email is valid 
	        else {
	            alert("The email address isn't valid.  Please use the following format: john@company.com");
	            return false;
	        }

	        if (document.form1.rAddress.value == "")
	        { alert("Please provide an email address for your friend"); return false }
	    }

	    function IsNumeric(sText) {
	        // Validate value is numeric
	        var ValidChars = "0123456789";
	        var IsNumber = true;
	        var Char;


	        for (i = 0; i < sText.length && IsNumber == true; i++) {
	            Char = sText.charAt(i);
	            if (ValidChars.indexOf(Char) == -1) {
	                alert("Please enter a numeric value.");
	                IsNumber = false;
	            }
	        }
	        return IsNumber;
	    }

	    function IsNumericCreditCard(sText) {
	        // Validate value is numeric
	        var ValidChars = "0123456789";
	        var IsNumber = true;
	        var Char;


	        for (i = 0; i < sText.length && IsNumber == true; i++) {
	            Char = sText.charAt(i);
	            if (ValidChars.indexOf(Char) == -1) {
	                IsNumber = false;
	            }
	        }
	        return IsNumber;
	    }

	    function ValidateMinOrderQty(SelectedItem, SelectedQty, GoToItem) {

	        // Validate order qty is not less than minimum order qty

	        var strIndex1
	        var strIndex2
	        var strItem
	        var strMinQty

	        strIndex1 = SelectedItem.indexOf("-Item=");
	        strIndex2 = SelectedItem.indexOf("-ItemMinQty=");

	        strItem = SelectedItem.substring(strIndex1 + 6, strIndex2);
	        strMinQty = SelectedItem.substring(strIndex2 + 12);

	        if (parseFloat(SelectedQty) < parseFloat(strMinQty)) {
	            alert("The minimum order quantity for item " + strItem + " is " + strMinQty + ". Please enter a minimum of " + strMinQty + " and try again.");
	            if (GoToItem == "TRUE") {
	                document.getElementById(SelectedItem).focus();
	                document.getElementById(SelectedItem).select();
	            }
	            return false
	        }
	    }

	    function ValidateOrderQty(ItemIdList) {

	        var x
	        var SelectedQty
	        var SelectedItem
	        var ItemList = ItemIdList
	        var ItemArrayList = new Array()

	        ItemArrayList = ItemList.split(",")

	        for (x in ItemArrayList) {
	            // Get the item and min order quantity
	            SelectedItem = ItemArrayList[x]

	            // Get the order quantity
	            SelectedQty = document.getElementById(ItemArrayList[x]).value

	            // Validate qty entered
	            if (SelectedQty == "0") {
	                alert("Please enter a quantity greater than zero");
	                return false
	            }
	            if (SelectedQty == "") {
	                alert("Please enter a quantity");
	                return false
	            }

	            // Validate order qty is numeric
	            if (IsNumeric(SelectedQty) == false) {
	                return false
	            }

	            // Validate order qty is not less than minimum order qty
	            if (ValidateMinOrderQty(SelectedItem, SelectedQty, "TRUE") == false) {
	                return false
	            }

	        }

	    } // End function	

	    function ValidateRequiredPersonalization() {

	        var ItemIdList

	        ItemIdList = document.getElementById("PersonalizationIdListRequired").value

	        if (ItemIdList == "") {
	            return true
	        }

	        else {

	            var x
	            var SelectedId
	            var SelectedIdResult
	            var ItemList = ItemIdList
	            var ItemArrayList = new Array()

	            ItemArrayList = ItemList.split(",")

	            for (x in ItemArrayList) {
	                // Get the id
	                SelectedId = "PersonalizationAnswer" + ItemArrayList[x]

	                // Get the result
	                SelectedIdResult = document.getElementById(SelectedId).value

	                // Validate field is populated
	                if (SelectedIdResult == "") {
	                    alert("Please complete all required fields.");
	                    return false
	                }
	            }
	        }
	    }


	    function AddToCartValidation(SelectedItem, SelectedQty, SelectedOptionGroup, SelectedOption) {
	        if (document.cookie == "") {
	            alert("Our Web site requires that cookies be enabled in your Web browser.  We use cookies strictly for the purpose of managing your shopping cart.  To enable cookies please do the following: (1) Internet Explorer Users: Click Tools > Internet Options > Privacy tab and set to Medium (2) FireFox Users:  Click Tools > Options > Privacy tab and set to Accept Cookies from Sites.");
	            return false
	        }
	        if (SelectedItem == "0") {
	            alert("Please select an item from the selection box");
	            return false
	        }
	        if (SelectedOptionGroup == "1") {
	            if (SelectedOption == "0") {
	                alert("Please select an option from the selection box");
	                return false
	            } 
	        }
	        if (SelectedQty == "0") {
	            alert("Please enter a quantity greater than zero");
	            return false
	        }
	        if (SelectedQty == "") {
	            alert("Please enter a quantity");
	            return false
	        }

	        // Validate required fields for personalization
	        if (ValidateRequiredPersonalization() == false) {
	            return false;
	        }

	        // Validate order qty is not less than minimum order qty
	        if (ValidateMinOrderQty("-Item=" + SelectedItem, SelectedQty, "FALSE") == false) {
	            return false;
	        }

	        // Validate order qty is numeric
	        if (IsNumeric(SelectedQty) == false) {
	            return false;
	        }

	    } // End function		

	    function HyperLinkUrl(url) {
	        var newPage = url

	        if (newPage != "") {
	            window.location = newPage
	        }
	    }

	    function jumpPage(newLoc) {
	        newPage = newLoc.options[newLoc.selectedIndex].value

	        if (newPage != "") {
	            window.location = newPage
	        }
	    }

	    function GiftCardCurrentValue(PageURl) {

	        var eGiftCardNumber = document.getElementById("eGiftCardNumber").value
	        var eGiftCardPin = document.getElementById("eGiftCardPin").value
	        var eGiftCardError = false

	        if (eGiftCardNumber == "") {
	            eGiftCardError = true;
	            alert("Please enter your e-gift card number.");
	        }

	        if (eGiftCardPin == "") {
	            eGiftCardError = true;
	            alert("Please enter your e-gift card pin.");
	        }


	        if (eGiftCardError == false) {
	            var page = PageURl + "/GiftCardValue.aspx?GCN=" + eGiftCardNumber + "&GCP=" + eGiftCardPin
	            //var page = "http://localhost:3227/GiftCardValue.aspx?GCN="+eGiftCardNumber+"&GCP="+eGiftCardPin
	            var PxWidth = "580"
	            var PxHeight = "485"

	            PageWindow(page, PxWidth, PxHeight)
	        }

	    }

	    function ShippingRateWindow(page, PxWidth, PxHeight) {

	        // validate variables
	        
	          var intCountryID = document.getElementById("country").value
	          var strState = document.getElementById("stateShip").value
	          var strZip = document.getElementById("ShipToZip").value

	        if (intCountryID == "0") {
	            alert("You must select a Country");
	            return false;
	        }

	        if (intCountryID == "1" && strState == "" || intCountryID == "40" && strState == "") {
	            alert("You must select a State / Province");
	            return false;
	        }

	        if (intCountryID == "1" && strZip == "" || intCountryID == "40" && strZip == "") {
	            alert("You must enter a Zip / Postal Code");
	            return false;
	        } 
	    
	        //open the popup
	        var leftPos = 0
	        var topPos = 0
	        if (screen) {
	            leftPos = (screen.width - PxWidth) / 2
	            topPos = (screen.height - PxHeight) / 2
	        }

	        var newPage = page + "?ShiptoCountry=" + intCountryID + "&stateShip=" + strState + "&ShiptoZip=" + strZip

	        if (newPage != "") {
	            pgShipRateWindow = window.open(newPage, "ShippingRateWindow", "width=" + PxWidth + ",height=" + PxHeight + ",left=" + leftPos + ",top=" + topPos + ",scrollbars=yes")
	            pgShipRateWindow.focus();
	            LoadModalDiv();
	        }

	        //close the shipping selection div
	        ToggleDivDisplay('divShippingSelection', 'divShippingSelectionToggle') 
	        
	    }

	    function PageWindow(page, PxWidth, PxHeight) {
	        var leftPos = 0
	        var topPos = 0
	        if (screen) {
	            leftPos = (screen.width - PxWidth) / 2
	            topPos = (screen.height - PxHeight) / 2
	        }

	        var newPage = page

	        if (newPage != "") {
	            pgWindow = window.open(newPage, "PageWindow", "width=" + PxWidth + ",height=" + PxHeight + ",left=" + leftPos + ",top=" + topPos + ",scrollbars=yes")
	            pgWindow.focus();
	            LoadModalDiv();
	        }
	    }

	    function PriceListWindow(page, PxWidth, PxHeight) {
	        var leftPos = 0
	        var topPos = 0
	        if (screen) {
	            leftPos = (screen.width - PxWidth) / 2
	            topPos = (screen.height - PxHeight) / 2
	        }

	        var newPage = page

	        if (newPage != "") {
	            invWindow = window.open(newPage, "PriceListWindow", "width=" + PxWidth + ",height=" + PxHeight + ",left=" + leftPos + ",top=" + topPos + ",scrollbars=yes")
	            invWindow.focus();
	            LoadModalDiv();
	        }
	    }

	    function inventoryWindow(page) {
	        var leftPos = 0
	        var topPos = 0
	        if (screen) {
	            leftPos = (screen.width - 580) / 2
	            topPos = (screen.height - 485) / 2
	        }

	        var newPage = page.options[page.selectedIndex].value

	        if (newPage != "") {
	            invWindow = window.open(newPage, "inventoryWin", "width=580,height=485,left=" + leftPos + ",top=" + topPos + ",scrollbars=yes")
	            invWindow.focus();
	            LoadModalDiv();
	        }
	    }

	    function questionWindow(question) {
	        leftPos = 0
	        topPos = 0
	        if (screen) {
	            leftPos = (screen.width - 580) / 2
	            topPos = (screen.height - 485) / 2
	        }
	        queWindow = window.open(question, "questionWin", "width=580,height=485,left=" + leftPos + ",top=" + topPos + ",scrollbars=yes");
	        queWindow.focus();
	        LoadModalDiv();
	    }

	    function addressWindow(address) {

	        var strAddress = address;
	        var RegExp = /#|'/g;

	        strAddress = String(address).replace(RegExp, "")

	        leftPos = 0
	        topPos = 0
	        if (screen) {
	            leftPos = (screen.width - 580) / 2
	            topPos = (screen.height - 485) / 2
	        }
	        addrWindow = window.open(strAddress, "addressWin", "width=580,height=485,left=" + leftPos + ",top=" + topPos + ",scrollbars=yes")
	        addrWindow.focus();
	        LoadModalDiv();

	    }

	    // pop up window load modal
	    function LoadModalDiv() {
	        var bcgDiv = document.getElementById("divBackground");
	        bcgDiv.style.display = "block";
	        if (bcgDiv != null) {
	            if (document.body.clientHeight > document.body.scrollHeight) {
	                bcgDiv.style.height = document.body.clientHeight + "px";
	            }
	            else {
	                bcgDiv.style.height = document.body.scrollHeight + "px";
	            }
	            bcgDiv.style.width = "100%";
	        }
	    }

	    // pop up window hide modal
	    function HideModalDiv() {
	        var bcgDiv = document.getElementById("divBackground");
	        bcgDiv.style.display = "none";
	    }

	    // on close pop up window modal
	    function OnCloseModalPopup() {
	        if (window.opener != null && !window.opener.closed) {
	            window.opener.HideModalDiv();
	        }
	    }
	    
	    function updateAddress(firstNameShip, lastNameShip, companyShip, streetShip, street2Ship, cityShip, stateShip, zipShip, phoneShip, emailShip, ShipToLocType, countryShip) {

	        opener.document.checkout.firstNameShip.value = firstNameShip
	        opener.document.checkout.lastNameShip.value = lastNameShip
	        opener.document.checkout.companyShip.value = companyShip
	        opener.document.checkout.streetShip.value = streetShip
	        opener.document.checkout.street2Ship.value = street2Ship
	        opener.document.checkout.cityShip.value = cityShip
	        opener.document.checkout.zipShip.value = zipShip
	        opener.document.checkout.phoneShip.value = phoneShip
	        opener.document.checkout.emailShip.value = emailShip
	        opener.document.checkout.countryShip.value = countryShip

	        if (countryShip != 1 && countryShip != 40) {
	            opener.document.getElementById('ShipToState').innerHTML = '<input type=text id=stateShip name=stateShip value=' + stateShip + ' />';
	        }
	        else {
	            opener.document.getElementById('ShipToState').innerHTML = '<select id=stateShip name=stateShip><option value=' + stateShip + '>' + stateShip + '</option></select>';
	        }

	        if (ShipToLocType == 0) {
	            opener.document.checkout.radioA.checked = true
	        }
	        else {
	            opener.document.checkout.radioB.checked = true
	        }

	        window.close()

	    }

	    function statPending(newStat) {
	        Load = "account.asp?orderstatus=Pending"
	        window.location = Load
	    }


	    function statClosed(newStat) {
	        Load = "account.asp?orderstatus=Closed"
	        window.location = Load
	    }


	    function statCancelled(newStat) {
	        Load = "account.asp?orderstatus=Cancelled"
	        window.location = Load
	    }


	    function statPendClosed(newStat) {
	        Load = "account.asp"
	        window.location = Load
	    }

	    function MsgWindow(MsgText, MsgTitle, PxWidth, PxHeight) {
	        var leftPos = 0
	        var topPos = 0
	        if (screen) {
	            leftPos = (screen.width - PxWidth) / 2
	            topPos = (screen.height - PxHeight) / 2
	        }


	        mWindow = window.open("", "MsgWindow", "width=" + PxWidth + ",height=" + PxHeight + ",left=" + leftPos + ",top=" + topPos + ",scrollbars=yes")
	        mWindow.document.write("<html>")
	        mWindow.document.write("<head>")
	        mWindow.document.write("<title> " + MsgTitle + "</title>")
	        mWindow.document.write("<link rel=stylesheet type=text/css href=cartgenie/CartGenieMaster.css />")
	        mWindow.document.write("<script src=functions.js language=javascript type=text/javascript></script>")
	        mWindow.document.write("<script type=text/javascript>")
	        mWindow.document.write("window.onunload = OnCloseModalPopup;")
	        mWindow.document.write("</script>")
	        mWindow.document.write("</head>")
	        mWindow.document.write("<body><table>")
	        mWindow.document.write("<tr><td class=cg_text3>")
	        mWindow.document.write(MsgText)
	        mWindow.document.write("</td></tr></table>")
	        mWindow.document.write("</body></html>")
	        mWindow.focus();
	        LoadModalDiv();

	    }


	    function newWindow(iLocation, iName) {
	        prdWindow = window.open("", "newWin", "width=680,height=485")
	        prdWindow.document.write("<html>")
	        prdWindow.document.write("<head><title> " + iName)
	        prdWindow.document.write("</title></head>")
	        prdWindow.document.write("<body><table align=center valign=bottom>")
	        prdWindow.document.write("<tr><td align=center><a href='' onClick='window.close()'>Close Window</a></td></tr>")
	        prdWindow.document.write("<tr><td>")
	        prdWindow.document.write(iLocation)
	        prdWindow.document.write("</td></tr></table>")
	        prdWindow.document.write("</body></html>")
	        prdWindow.document.close()
	    }


	    function cmpListWindow(cList) {
	        leftPos = 0
	        topPos = 0
	        if (screen) {
	            leftPos = (screen.width - 560) / 2
	            topPos = (screen.height - 500) / 2
	        }
	        cmpWindow = window.open(cList, "cmpList", "width=560,height=500,left=" + leftPos + ",top=" + topPos + ",scrollbars=yes,resizable=no")
	        cmpWindow.focus();
	        LoadModalDiv();
	    }


	    function imageWindow(image) {
	        leftPos = 0
	        topPos = 0
	        if (screen) {
	            leftPos = (screen.width - 680) / 2
	            topPos = (screen.height - 485) / 2
	        }
	        imgWindow = window.open(image, "imageWin", "width=680,height=485,left=" + leftPos + ",top=" + topPos + ",scrollbars=yes,resizable=yes")
	        imgWindow.focus();
	        LoadModalDiv();
	    }

	    function CloseAndGoTo(newLocation) {
	        opener.location = newLocation;
	        window.close()
	    }

	    function GoToProdInfo(newLocation) {
	        opener.location = newLocation;
	    }


	    function GoToCart(newCart) {
	        opener.location = newCart;
	    }

	    function setShipToLoc(shipVal) {
	        window.document.checkout.ShipToLocType.value = shipVal
	    }

	    function copyInfo() {

	        document.checkout.firstNameShip.value = document.checkout.firstName.value;
	        document.checkout.lastNameShip.value = document.checkout.lastName.value;
	        document.checkout.companyShip.value = document.checkout.company.value;
	        document.checkout.streetShip.value = document.checkout.street.value;
	        document.checkout.street2Ship.value = document.checkout.street2.value;
	        document.checkout.street3Ship.value = document.checkout.street3.value;
	        document.checkout.cityShip.value = document.checkout.city.value;
	        document.checkout.zipShip.value = document.checkout.zip.value;
	        document.checkout.phoneShip.value = document.checkout.phone.value;
	        document.checkout.emailShip.value = document.checkout.email.value;
	        document.checkout.countryShip.value = document.checkout.country.value;
	        AjaxHandler('ShipToState', document.checkout.country.value,'stateShip', document.getElementById("state").value);

	    }

	    function FormValidationChk0() {

	        // Check for blank bill-to fields 

	        if (document.checkout.firstName.value == "") {
	            alert("The bill-to first name isn't valid");
	            document.checkout.firstName.focus();
	            document.checkout.firstName.select();
	            return false
	        }

	        if (document.checkout.lastName.value == "") {
	            alert("The bill-to last name isn't valid");
	            document.checkout.lastName.focus();
	            document.checkout.lastName.select();
	            return false
	        }

	        if (document.checkout.street.value == "") {
	            alert("The bill-to street name isn't valid");
	            document.checkout.street.focus();
	            document.checkout.street.select();
	            return false
	        }

	        if (document.checkout.city.value == "") {
	            alert("The bill-to city name isn't valid");
	            document.checkout.city.focus();
	            document.checkout.city.select();
	            return false
	        }

	        // Validate the bill-to state code
	        if (document.checkout.country.value == 1 || document.checkout.country.value == 40) {
	            if (document.getElementById("state").value == "") {
	                alert("The bill-to state / province name isn't valid");
	                document.getElementById("state").focus();
	                return false
	            }
	        }

	        // Validate the bill-to zip code for usa
	        if (document.checkout.country.value == 1) {
	            if (reZipCode.test(window.document.checkout.zip.value))
	            { }
	            else {
	                alert("The bill-to zip code isn't valid");
	                document.checkout.zip.focus();
	                document.checkout.zip.select();
	                return false
	            }
	        }

	        // Validate the bill-to phone number for usa
	        if (document.checkout.country.value == 1) {
	            validPhoneBill = rePhone.exec(window.document.checkout.phone.value)
	            if (validPhoneBill)
	            { window.document.checkout.phone.value = +validPhoneBill[1] + "-" + validPhoneBill[2] + "-" + validPhoneBill[3] }
	            else {
	                alert("The bill-to phone number isn't valid.  Please use the following format, 555-555-5555, and ensure there are no trailing spaces after the last number.")
	                window.document.checkout.phone.focus()
	                window.document.checkout.phone.select();
	                return false
	            }
	        }

	        // Validate the bill-to email address	
	        if (reEmail.test(document.checkout.email.value))
	        { } // The email is valid 
	        else {
	            alert("The bill-to email address isn't valid.  Please use the following format: john@company.com")
	            window.document.checkout.email.focus()
	            window.document.checkout.email.select();
	            return false
	        }


	        // Check for blank ship-to fields 
	        if (document.getElementById("ShipToDisplayFlag").value == "1") {

	            if (document.checkout.firstNameShip.value == "") {
	                alert("The ship-to first name isn't valid");
	                document.checkout.firstNameShip.focus();
	                document.checkout.firstNameShip.select();
	                return false
	            }

	            if (document.checkout.lastNameShip.value == "") {
	                alert("The ship-to last name isn't valid");
	                document.checkout.lastNameShip.focus();
	                document.checkout.lastNameShip.select();
	                return false
	            }

	            if (document.checkout.streetShip.value == "") {
	                alert("The ship-to street name isn't valid");
	                document.checkout.streetShip.focus();
	                document.checkout.streetShip.select();
	                return false
	            }

	            if (document.checkout.countryShip.value == 176 && trimAll(document.checkout.street3Ship.value) == "") {
	                alert("The Urbanization Address is required in the Address Line 3 field for orders to Puerto Rico.");
	                document.checkout.street3Ship.focus();
	                document.checkout.street3Ship.select();
	                return false
	            }

	            // check for po box	
	            var sStreetShip = document.checkout.streetShip.value;
	            sStreetShip = sStreetShip.toUpperCase();
	            var sPOBoxCheck1 = sStreetShip.indexOf("P.O. BOX");
	            var sPOBoxCheck2 = sStreetShip.indexOf("PO BOX");
	            var sPOBoxCheck3 = sStreetShip.indexOf("P O BOX");
	            var sPOBoxCheck4 = sStreetShip.indexOf("PO. BOX");
	            var sPOBoxCheck5 = sStreetShip.indexOf("P.O BOX");

	            if (document.getElementById("AllowPOBox").value == "False") {
	                if (sPOBoxCheck1 == "0" || sPOBoxCheck2 == "0" || sPOBoxCheck3 == "0" || sPOBoxCheck4 == "0" || sPOBoxCheck5 == "0") {
	                    alert("The ship-to street address can not be a P.O. Box");
	                    document.checkout.streetShip.focus();
	                    document.checkout.streetShip.select();
	                    return false
	                }
	            }

	            if (document.checkout.cityShip.value == "") {
	                alert("The ship-to city name isn't valid");
	                document.checkout.cityShip.focus();
	                document.checkout.cityShip.select();
	                return false
	            }

	            // Validate the ship-to state code
	            if (document.checkout.countryShip.value == 1 || document.checkout.countryShip.value == 40) {
	                if (document.getElementById("stateShip").value == "") {
	                    alert("The ship-to state / province name isn't valid");
	                    document.getElementById("stateShip").focus();
	                    return false
	                }
	            }

	            // Validate the ship-to zip code
	            if (document.checkout.countryShip.value == 1) {
	                if (reZipCode.test(window.document.checkout.zipShip.value))
	                { }
	                else {
	                    alert("The ship-to zip code isn't valid");
	                    document.checkout.zipShip.focus();
	                    document.checkout.zipShip.select();
	                    return false
	                }
	            }

	            // Validate the ship-to phone number
	            if (window.document.checkout.countryShip.value == 1) {
	                validPhoneShip = rePhone.exec(window.document.checkout.phoneShip.value)
	                if (validPhoneShip)
	                { window.document.checkout.phoneShip.value = +validPhoneShip[1] + "-" + validPhoneShip[2] + "-" + validPhoneShip[3] }
	                else {
	                    alert("The ship-to phone number isn't valid.  Please use the following format: 555-555-5555.")
	                    window.document.checkout.phoneShip.focus()
	                    window.document.checkout.phoneShip.select();
	                    return false
	                }
	            }

	            // Validate the ship-to email address	
	            if (reEmail.test(window.document.checkout.emailShip.value))
	            { } // The email is valid 
	            else {
	                alert("The ship-to email address isn't valid.  Please use the following format: john@company.com")
	                window.document.checkout.emailShip.focus()
	                window.document.checkout.emailShip.select();
	                return false
	            }
	        }

	        // Validate User Defined 6 
	        if (document.checkout.reg_user_defined6_required_flag.value == "REQUIRED") {
	            if (document.getElementById("ud1").value == "") {
	                alert("The following information is required: " + document.checkout.user_defined6_label.value);
	                document.checkout.user_defined6.focus();
	                document.checkout.user_defined6.select();
	                return false
	            }
	        }

	        // Validate User Defined 7
	        if (document.checkout.reg_user_defined7_required_flag.value == "REQUIRED") {
	            if (document.getElementById("ud2").value == "") {
	                alert("The following information is required: " + document.checkout.user_defined7_label.value);
	                document.checkout.user_defined7.focus();
	                document.checkout.user_defined7.select();
	                return false
	            }
	        }

	        // Validate User Defined 8
	        if (document.checkout.reg_user_defined8_required_flag.value == "REQUIRED") {
	            if (document.getElementById("ud3").value == "") {
	                alert("The following information is required: " + document.checkout.user_defined8_label.value);
	                document.checkout.user_defined8.focus();
	                document.checkout.user_defined8.select();
	                return false
	            }
	        }


	        // Validate customer comments length
	        if (document.getElementById("customerComments").value != "") {
	            if (ValidateStrLength(document.checkout.customerComments.value, 0, 255) == false) {
	                alert("The maximum number of characters allowed in Comments is 255");
	                document.checkout.customerComments.focus();
	                document.checkout.customerComments.select();
	                return false
	            }
	        }


	        // Validate terms and conditions		
	        if (document.checkout.vTermsConditions.value == 1) {
	            if (document.checkout.terms.checked == false) {
	                alert("You must check the Terms & Conditions box before moving forward");
	                document.checkout.terms.focus();
	                return false
	            } 
	        }

	    }  // End function
   

		