// JavaScript Document

function validation(obj, arrayObj){
	
	
	
	                                                  for(var i = 0; i < arrayObj.length; i++){
		
		
		
          if ( arrayObj[i] == "email" ){
		  if(   (  (obj.email.value.indexOf(".") <= 1) || (obj.email.value.indexOf("@") <= 1) )  ){
          alert("Please enter a correct email address");
          obj.email.focus();
          return false;
		  } 
		  }
		  
		  if ( arrayObj[i] == "username" ){
		   if(obj.username.value == ""){
		   alert("Please enter a username, thank you");
		   obj.username.focus();
		   return false;
		   }
		   }		

           if ( arrayObj[i] == "password" ){
		   if(obj.password.value == ""){
		   alert("Please enter a password, thank you");
		   obj.password.focus();
		   return false;
		   }
		   }		
		   
		    if ( arrayObj[i] == "reTypePassword" ){
		   if(obj.reTypePassword.value == ""){
		   alert("Please re-type your password, thank you");
		   obj.reTypePassword.focus();
		   return false;
		   }
		   else if(obj.reTypePassword.value != obj.password.value){
		   alert("your re-typed password does not match");
		   obj.reTypePassword.focus();
		   return false;
		   }
		   }		
			
		   if ( arrayObj[i] == "firstName" ){
		   if(obj.firstName.value == ""){
		   alert("Please enter your first name, thank you");
		   obj.firstName.focus();
		   return false;
		   }
		   }		
			
		   if ( arrayObj[i] == "lastName" ){
		   if(obj.lastName.value == ""){
		   alert("Please enter your last name, thank you");
		   obj.lastName.focus();
		   return false;
		   }
		   }		
			
		   if ( arrayObj[i] == "address1" ){
		   if(obj.address1.value == ""){
		   alert("Please enter your address, thank you");
		   obj.address1.focus();
		   return false;
		   }
		   }		
		
				
		   if ( arrayObj[i] == "city1" ){
		   if(obj.city1.value == ""){
		   alert("Please enter your city, thank you");
		   obj.city1.focus();
		   return false;
		   }
		   }	
			
			
			
			
			
			if ( arrayObj[i] == "state1" ){
			if(obj.state1.selectedIndex==0){
	         	alert("Please select your state");
				obj.state1.focus();
				return (false);
			}
	        if(obj.state1.selectedIndex<0){
		  	  alert("Please select your state");
		  	  obj.state1.focus();
		  	  return (false);
	       }
		   }	
		   
		   
		   if ( arrayObj[i] == "zip1" ){
		   if(obj.zip1.value == ""){
		   alert("Please enter your zip code, thank you");
		   obj.zip1.focus();
		   return false;
		   }
		   }	
		   
		   if ( arrayObj[i] == "country1" ){
		   if(obj.country1.selectedIndex==0){
	         	alert("Please select your country");
				obj.country1.focus();
				return (false);
			}
	        if(obj.country1.selectedIndex<0){
		  	  alert("Please select your country");
		  	  obj.country1.focus();
		  	  return (false);
	       }
		   }	
		   
		   if ( arrayObj[i] == "telephone1" ){
		   if(obj.telephone1.value == ""){
		   alert("Please enter your telephone, thank you");
		   obj.telephone1.focus();
		   return false;
		   }
		   }	
		   
		   
		   
		   
		  if ( arrayObj[i] == "accountType" ){
	
	//i commented this out because at the moment there are only 3 quarters to choose from...
         if(       ( obj.accountType[0].checked==false )&&
                   ( obj.accountType[1].checked==false )
				   /***  THERE USED TO BE 4 OPTIONS NOW ONLY TWO 
				   &&
                   ( obj.accountType[2].checked==false )&&
                   ( obj.accountType[3].checked==false )       
				   ***/
				   )
		 
	     { 
	     alert("Please select the type of subscription you would like.");
	     obj.accountType[0].focus();
	     return (false);
	     }
	     }
	
	
		   
		   if ( arrayObj[i] == "creditCardType" ){
		   if(obj.creditCardType.selectedIndex==0){
	         	alert("Please select your credit card type");
				obj.creditCardType.focus();
				return (false);
			}
	        if(obj.creditCardType.selectedIndex<0){
		  	  alert("Please select your credit card type");
		  	  obj.creditCardType.focus();
		  	  return (false);
	       }
		   }	
		   
		   if ( arrayObj[i] == "creditCardNumber" ){
		   if(obj.creditCardNumber.value == ""){
		   alert("Please enter your credit card number, thank you");
		   obj.creditCardNumber.focus();
		   return false;
		   }
		   }	
		   
		   if ( arrayObj[i] == "creditCardExpirationMonth" ){
		   if(obj.creditCardExpirationMonth.selectedIndex==0){
	         	alert("Please select your credit card month");
				obj.creditCardExpirationMonth.focus();
				return (false);
			}
	        if(obj.creditCardExpirationMonth.selectedIndex<0){
		  	  alert("Please select your credit card month");
		  	  obj.creditCardExpirationMonth.focus();
		  	  return (false);
	       }
		   }	
			
			
		   if ( arrayObj[i] == "creditCardExpirationYear" ){
		    if(obj.creditCardExpirationYear.selectedIndex==0){
	         	alert("Please select your credit card year");
				obj.creditCardExpirationYear.focus();
				return (false);
			}
	        if(obj.creditCardExpirationYear.selectedIndex<0){
		  	  alert("Please select your credit card year");
		  	  obj.creditCardExpirationYear.focus();
		  	  return (false);
	       }
		   }	
			
			
		   if ( arrayObj[i] == "ccv" ){
		   if(obj.ccv.value == ""){
		   alert("Please enter your credit card ccv, thank you");
		   obj.ccv.focus();
		   return false;
		   }
		   }	
			
			
			
			
			
			
			
			
			
			
			
			
													   
													   
													   
													   
													   
													   
													   } //for loop
	
	
	
	
	
	return true;
	
	
	}//end of function