function checkForm(form){
	var cont = true;
	f=form;
	if(typeof(f)=='object'){
		if(typeof(form.company)=='object'){
//			if (form.company.value == "" && cont){
//				alert("You Must Enter Your Company Name.  If You Do Not Have A Company Name, Then Please Enter Your Full Name.");
//				cont = false;
//			}
			
			c=checkSmut(form.company.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (Company Field).");
				cont=false;
			}
			if(form.company.value!="" && cont){
				changeCase(form.company);
			}
		}
		if(typeof(form.firstName)=='object'){
			if (form.firstName.value == "" && cont){
				alert("You Must Enter Your First Name.");
				cont = false;
			}
			c=checkSmut(form.firstName.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (First Name Field).");
				cont=false;
			}
			if(form.firstName.value!="" && cont){
				changeCase(form.firstName);
			}
		}
		if(typeof(form.lastName)=='object'){
			if (form.lastName.value == "" && cont){
				alert("You Must Enter Your Last Name.");
				cont = false;
			}
			c=checkSmut(form.lastName.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (Last Name Field).");
				cont=false;
			}
			if(form.lastName.value!="" && cont){
				changeCase(form.lastName);
			}
		}
		if(typeof(form.password)=='object'){
			if (form.password.value == "" && cont){
				alert("You Must Enter Your Password.");
				cont = false;
			}
			c=checkSmut(form.password.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (Password Field).");
				cont=false;
			}
		}
		if(typeof(form.address1)=='object'){
			if (form.address1.value == "" && cont){
				alert("You Must Enter Your Address.");
				cont = false;
			}
			c=checkSmut(form.address1.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (Address1 Field).");
				cont=false;
			}
			if(form.address1.value!="" && cont){
				changeCase(form.address1);
			}
		}
		if(typeof(form.city)=='object'){
			if (form.city.value == "" && cont){
				alert("You Must Enter Your City.");
				cont = false;
			}
			c=checkSmut(form.city.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (City Field).");
				cont=false;
			}
			if(form.city.value!="" && cont){
				changeCase(form.city);
			}
		}
		if(typeof(form.state)=='object'){
			if (form.state.value == "" && cont){
				alert("You Must Enter Your State.");
				cont = false;
			}
			c=checkSmut(form.state.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (State Field).");
				cont=false;
			}
			if(form.state.value!="" && cont){
				changeCase(form.state);
			}
		}
		if(typeof(form.zipCode)=='object'){
			if (form.zipCode.value == "" && cont){
				alert("You Must Enter Your Zip Code.");
				cont = false;
			}
			c=checkSmut(form.zipCode.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (Zip Code Field).");
				cont=false;
			}
			if(form.zipCode.value!="" && cont){
				changeCase(form.zipCode);
			}
		}
		if(typeof(form.country)=='object'){
			if (form.country.value == "" && cont){
				alert("You Must Enter Your Country.");
				cont = false;
			}
			c=checkSmut(form.country.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (Country Field).");
				cont=false;
			}
			if(form.country.value!="" && cont){
				changeCase(form.country);
			}
		}
		if(typeof(form.emailAddress)=='object'){
			if (form.emailAddress.value == "" && cont){
				alert("You Must Enter Your Email Address.");
				cont = false;
			}
			c=checkSmut(form.emailAddress.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (Email Address Field).");
				cont=false;
			}
		}
		if(typeof(form.phone)=='object'){
			if (form.phone.value == "" && cont){
				alert("You Must Enter Your Phone Number.");
				cont = false;
			}
			c=checkSmut(form.phone.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (Phone Field).");
				cont=false;
			}
			/*if(isNaN(form.phone.value) && cont){
				alert("Only numbers are allowed in the phone text box.  Please re-enter.");
				cont=false;
			}*/
		}
		// check for vulgar word in the shipping fields
		if(typeof(form.ship_company)=='object'){
		c=checkSmut(form.ship_company.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (Company Field - Shipping).");
				cont=false;
			}
		}
		if(typeof(form.ship_firstName)=='object'){
		c=checkSmut(form.ship_firstName.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (First Name Field - Shipping).");
				cont=false;
			}
		}
		if(typeof(form.ship_lastName)=='object'){
		c=checkSmut(form.ship_lastName.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (Last Name Field - Shipping).");
				cont=false;
			}
		}
		if(typeof(form.ship_address1)=='object'){
		c=checkSmut(form.ship_address1.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (Address1 Field - Shipping).");
				cont=false;
			}
		}
		if(typeof(form.ship_city)=='object'){
		c=checkSmut(form.ship_city.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (City Field - Shipping).");
				cont=false;
			}
		}
		if(typeof(form.ship_state)=='object'){
		c=checkSmut(form.ship_state.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (State Field - Shipping).");
				cont=false;
			}
		}
		if(typeof(form.ship_zip)=='object'){
		c=checkSmut(form.ship_zip.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (Zip Field - Shipping).");
				cont=false;
			}
		}
		if(typeof(form.ship_country)=='object'){
		c=checkSmut(form.ship_country.value);
			if(c && cont){
				alert("There appears to be vulgar language in the text field.  Please re-enter your information (Company Field - Shipping).");
				cont=false;
			}
		}
		// from the purchase page
		
		if(typeof(form.ssl_card_number)=='object'){
			if (form.ssl_card_number.value == "" && cont){
				alert("You Must Enter Your Credit Card Number.");
				cont = false;
			}
			/*if(isNaN(form.ssl_card_number) && cont){
				alert("Only numbers are allowed for this entry (Credit Card Number).");
				cont=false;
			}*/
		}
		if(typeof(form.ssl_exp_date)=='object'){
			if (form.ssl_exp_date.value == "" && cont){
				alert("you Must Enter The Credit Card Expiration Date.");
				cont = false;
			}
			/*if(isNaN(form.ssl_exp_date) && cont){
				alert("Please enter the expiration date in the format mmyy");
				cont=false;
			}*/
		}
				
		if(cont) form.submit();
                else return false;
		//if(cont) document.form.submit();
	}
}

// validate email

function VerifyEmailAddress(){
  var Reason  = "Your Email Address appears incorrect.  \n\nPlease check. \n\nReason:"
  var Success = "Email Address entered Correctly!"
  var checkStr = document.form.emailAddress.value;
  var ix = (checkStr.length - 4)
  var RC = true;
  var x = AtSignValid = DoublePeriod = PeriodValid = SpaceValid = ExtValid = RL = 0;

  for (i = 0;  i < checkStr.length;  i++)
  {
    if (checkStr.charAt(i) == '@')
      AtSignValid++;
    else if (checkStr.charAt(i) == '.')
    {
      if (x == (i-1))
        DoublePeriod++;
      else
      {
        x = i;
        PeriodValid++;
      }
    }
    else if (checkStr.charAt(i) == ' ')
      SpaceValid ++;
  }
  if (checkStr.indexOf(".com", ix) > -1)
    ExtValid++;
  else if (checkStr.indexOf(".edu", ix) > -1)
    ExtValid++;
  else if (checkStr.indexOf(".net", ix) > -1)
    ExtValid++;
  else if (checkStr.indexOf(".org", ix) > -1)
    ExtValid++;
  else if (checkStr.indexOf(".gov", ix) > -1)
    ExtValid++;
  else if (checkStr.indexOf(".mil", ix) > -1)
    ExtValid++;
  else if (checkStr.indexOf(".cc", ix) > -1)
    ExtValid++;
  RL = Reason.length;
  if (AtSignValid != 1)
    Reason += "\nOnly one '@' allowed, " + AtSignValid + " found.";
  if (PeriodValid == 0)
    Reason += "\nAddress must contain at least one period.";
  if (SpaceValid > 0)
    Reason += "\nNo Spaces allowed. Address contains " + SpaceValid + " space";
  if (SpaceValid > 1)
    Reason += "s.";
  if (checkStr.length > 120)
    Reason += "\nPlease limit the Email Address to 120 characters.";

  if (RL != Reason.length)
  {
 alert(Reason);
 return false;
  }
  return true;
}

// make uppercase

function changeCase(frmObj) {
var index;
var tmpStr;
var tmpChar;
var preString;
var postString;
var strlen;
tmpStr = frmObj.value.toLowerCase();
strLen = tmpStr.length;
if (strLen > 0)  {
	for (index = 0; index < strLen; index++){
		if (index == 0)  {
			tmpChar = tmpStr.substring(0,1).toUpperCase();
			postString = tmpStr.substring(1,strLen);
			tmpStr = tmpChar + postString;
		}else{
				tmpChar = tmpStr.substring(index, index+1);
			if (tmpChar == " " && index < (strLen-1))  {
				tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
				preString = tmpStr.substring(0, index+1);
				postString = tmpStr.substring(index+2,strLen);
				tmpStr = preString + tmpChar + postString;
        	}
      	}
   	}
}
frmObj.value = tmpStr;
}

function OpenCVV(){
	thewindow = window.open('../cvv_info.html', 'cnew', config='height=400,width=450,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
	}
	
function clearField(){
	form.ssl_card_number.value="";
}


// check for bad words
function checkSmut(p){
//alert(p);
	smut="#@&*%!#@&*%!#@&*%!";
	cmp="sex babes shit fuck damn porno cum cunt prick pecker ass "
	+"asshole pedophile man-boy man/boy dong twat ";
	//txt=document.form.company.value;
	txt=p;
	tstx="";
	for (var i=0;i<16;i++){ //loop through the words in cmp
		pos=cmp.indexOf(" ");
		wrd=cmp.substring(0,pos);
		wrdl=wrd.length
		cmp=cmp.substring(pos+1,cmp.length);
		//alert(cmp);
		if(txt.indexOf(wrd)>-1){
			return true;
			break;
		}
	}
}
