

function validate(field) {
var valid = "abcdefghijklmnopqrstuvwxyz0123456789"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Invalid entry!  Only characters and numbers are accepted!");
field.focus();
field.select();
   }
}


function replaceChars(entry) {
out = "http://"; // replace this
add = ""; // with this
ttt = entry.toLowerCase();
temp = "" + ttt; // temporary holder

while (temp.indexOf(out)>-1) {
pos= temp.indexOf(out);
temp = "" + (temp.substring(0, pos) + add + 
temp.substring((pos + out.length), temp.length));
}
document.PersonalInfo.URL.value = temp;
}




function resetform() {
document.forms[0].elements[1]=="";
}

function submitForms() {
//if (isFname() && isLname() && isEmail() && isAddress() && isCity() && isCountry() && isState() && isZip() && isTelePh() && isCreditCard()) {
if (isFname() && isLname() && isEmail()) {
return true;
}
return false
}

function submitEmailForm() {
//if (isFname() && isLname() && isEmail() && isAddress() && isCity() && isCountry() && isState() && isZip() && isTelePh() && isCreditCard()) {
if (isSubscribeEmail()) {
return true;
}
return false
}

function textCounter(field, countfield, maxlimit) {
//crapcheck(BuyProduct.Comments);
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
//else 
//countfield.value = maxlimit - field.value.length;
}




function isProduct() {
if (document.forms[0].elements[3].selectedIndex < "1") {
alert ("The Product field is blank. \n Please select a product.")
document.forms[0].elements[3].focus();
return false;
}
return true;
}



function isFname() {
if (document.PersonalInfo.Bill_first_name.value == "")
{
alert ("The First Name field is blank. \n Please enter your first name.")
document.PersonalInfo.Bill_first_name.focus();
return false;
}
return true;
}


function isLname() {
if (document.PersonalInfo.Bill_last_name.value == "") {
alert ("The Last Name field is blank. \n Please enter your last name.")
document.PersonalInfo.Bill_last_name.focus();
return false;
}
return true;
}

function isEmail() {
if (document.PersonalInfo.Bill_email.value == "") {
alert ("The E-Mail field is blank. \n Please enter your E-Mail address.")
document.PersonalInfo.Bill_email.focus();
return false;
}
if (document.PersonalInfo.Bill_email.value.indexOf ('@',0) == -1 ||
document.PersonalInfo.Bill_email.value.indexOf ('.',0) == -1) {
alert ("The E-Mail field requires a \"@\" and a \".\"be used. \n Please re-enter your E-Mail address.")
document.PersonalInfo.Bill_email.select();
document.PersonalInfo.Bill_email.focus();
return false;
}
return true;
}

function isSubscribeEmail() {
if (document.PersonalInfo.email.value == "") {
alert ("The E-Mail field is blank. \n Please enter your E-Mail address.")
document.PersonalInfo.email.select();
document.PersonalInfo.email.focus();
return false;
}
if (document.PersonalInfo.email.value.indexOf ('@',0) == -1 ||
document.PersonalInfo.email.value.indexOf ('.',0) == -1) {
alert ("The E-Mail field requires a \"@\" and a \".\"be used. \n Please re-enter your E-Mail address.")
document.PersonalInfo.email.select();
document.PersonalInfo.email.focus();
return false;
}
return true;
}

function isAddress() {
if (document.PersonalInfo.Bill_address.value == "") {
alert ("The Address field is blank. \n Please type an Address.")
document.PersonalInfo.Bill_address.focus();
return false;
}
return true;
}


function isCity()
{
if (document.PersonalInfo.Bill_city.value == "")
{
alert ("The City field is blank. \n Please enter your city.")
document.PersonalInfo.Bill_city.focus();
return false;
}
return true;
}


function isCountry() {
//if (document.PersonalInfo.Bill_Country.value == "") {
if (document.PersonalInfo.Bill_Country.selectedIndex < "1") {
alert ("The Country field is blank. \n Please select a Country.")
document.PersonalInfo.Bill_Country.focus();
return false;
}
return true;
}

function isState() {
if (document.PersonalInfo.Bill_province.value == "") {
alert ("The state field is blank.\n Please enter your state.")
document.PersonalInfo.Bill_province.focus();
return false;
}
//alert (document.PersonalInfo.Bill_province.selectedIndex)
return true;
}

function isZip() {
if (document.PersonalInfo.Bill_postal_code.value == "") {
alert ("The Zip code field is blank. \n Please enter your Zip code.")
document.PersonalInfo.Bill_postal_code.focus();
return false;
}
return true;
}

function isTelePh() {
if (document.PersonalInfo.Bill_phone.value == "") {
alert ("The telephone number field is blank. \n Please enter your telephone number.")
document.PersonalInfo.Bill_phone.focus();
return false;
}
return true;
}

function isCardType() {
//if (document.PersonalInfo.CCType.value == "") {
if (document.PersonalInfo.CCType.selectedIndex < "1"){
alert ("The credit card type is blank. \n Please select your credit card type.")
document.PersonalInfo.CCType.focus();
return false;
}
return true;
}

function isCreditCard() {
if (document.PersonalInfo.credit_card_number.value == "") {
alert ("The credit card number field is blank. \n Please enter your credit card number.")
document.PersonalInfo.credit_card_number.focus();
return false;
}
return true;
}

function isExpiryMonth() {
//if (document.PersonalInfo.expire_month.value == "") {
if (document.PersonalInfo.expire_month.selectedIndex < "1"){
alert ("The credit card expiry date is blank. \n Please enter your credit card expiry date.")
document.PersonalInfo.expire_month.focus();
return false;
}
return true;
}

function isExpiryYear() {
//if (document.PersonalInfo.expire_year.value == "") {
if (document.PersonalInfo.expire_year.selectedIndex < "1"){
alert ("The credit card expiry year is blank. \n Please enter your credit card expiry date.")
document.PersonalInfo.expire_year.focus();
return false;
}
return true;
}