
//BEGIN ADD SUBSCRIBER FORM VALIDATION FUNCTION DEFINITIONS

function isInputFieldValid(string) {
   if (!string) return false;
   var iChars = "%";
   for (var i = 0; i < string.length; i++) {
      if (iChars.indexOf(string.charAt(i)) != -1)
         return false;
   }
   return true;
}

function isSelectValid(string) {
   if (string == "null")return false;
   return true;
}

function isCheckValid(string){
	if(string.checked == true)return true;
	return false;
}

function populateAddress(){
	join.eBillStreet.value = join.eBusStreet.value;
	join.eBillSuite.value = join.eBusSuite.value;
	join.eBillCity.value = join.eBusCity.value;
	join.sBillState.value = join.sBusState.value;
	join.eBillZip.value = join.eBusZip.value;
}


//END SUB-FUNCTION DEFINITIONS

//START MAIN FUNCTION FOR ADD SUBSCRIBER FORM VALIDATION
function isFormReady(form) {

    if (isInputFieldValid(form.name.value) == false) {
        alert("Enter your name.");
        form.name.focus();
        return false;
    }
	
	if (isInputFieldValid(form.companyName.value) == false) {
        alert("Please enter your company name.");
        form.companyName.focus();
        return false;
    }
	
	if (isInputFieldValid(form.title.value) == false) {
        alert("Please enter your title.");
        form.title.focus();
        return false;
    }

	if (isInputFieldValid(form.address.value) == false) {
        alert("Please enter your address.");
        form.address.focus();
        return false;
    }
	
	if (isInputFieldValid(form.city.value) == false) {
        alert("Please enter your city.");
        form.city.focus();
        return false;
    }

	if (isInputFieldValid(form.state.value) == false) {
        alert("Please enter your state.");
        form.state.focus();
        return false;
    }
	
	if (isInputFieldValid(form.zip.value) == false) {
        alert("Please enter your zip.");
        form.zip.focus();
        return false;
    }
	
	if (isInputFieldValid(form.country.value) == false) {
        alert("Please enter your country.");
        form.country.focus();
        return false;
    }
	
	if (isInputFieldValid(form.telephone.value) == false) {
        alert("Please enter your telephone number.");
        form.telephone.focus();
        return false;
    }
	
	if (isInputFieldValid(form.fax.value) == false) {
        alert("Please enter your fax number.");
        form.fax.focus();
        return false;
    }
	
	if (isInputFieldValid(form.email.value) == false) {
        alert("Please enter your emal address.");
        form.email.focus();
        return false;
    }
	
	if (isSelectValid(form.businessType.value) == false) {
        alert("Please select the your primary business.");
        form.businessType.focus();
        return false;
    }

	if (isSelectValid(form.jobDescription.value) == false) {
        alert("Please select the your job description.");
        form.jobDescription.focus();
        return false;
    }

}

// END MAIN FUNCTION


// ----------------------------------------------------------------------------------------------------------------------------


//BEGIN VIEW SUBSCRIBER FORM VALIDATION FUNCTION DEFINITIONS

function isFieldTypeValid(form) {

    for (var i = 0; i < form.radiobutton.length; i++) {
		if( form.radiobutton[i].checked == true ) {
			return true;
		}
	}

	return false;

}


function checkViewAllBox(thisform) {
	if(thisform.viewallcheckbox.checked == false) {
		return false;
	}
	return true;
	
}


function isNumberViewValid(string) {	

   if (!string) return false;
   var iChars = "*|,\":<>[]{}`\';()@&$#%";
	  
    if (iChars.indexOf(form.maxview.value.charAt(i)) != -1)
    	return false;
   
   return true;
} 


function changeCheckbox(form) {
	form.checked = false;
	

}


function changeMaxview(form) {
	form.value = "";
	

}


function delRecord(url) {
   if(confirm("Are you sure you want to delete the Subscriber?")) {
      location.href=url;
   }
}

//END SUB-FUNCTION DEFINITIONS


//START MAIN FUNCTION FOR VIEW SUBSCRIBERS FORM VALIDATION
function isViewSubsReady(form) {

    if (isFieldTypeValid(form) == false) {
        alert("Please choose a field type to order viewing the subscribers by");
		form.radiobutton[0].focus();
		return false;
    }

	if( checkViewAllBox(form) == false) {
	
		if (isNumberViewValid(form.maxview.value) == false) {
       		alert("Please enter an integer greater than 0 or select checkbox to view all");
			form.maxview.focus();
			return false;
    	}
		
	}
    
	return true;

}
// END MAIN FUNCTION FOR VIEW SUBSCRIBERS



// ----------------------------------------------------------------------------------------------------------------------------


//BEGIN SEARCH SUBSCRIBER FORM VALIDATION FUNCTION DEFINITIONS
function isFieldValid(string) {

   if (!string) return false;

   return true;
} 

function isFieldRadioValid(form) {

    for (var i = 0; i < form.fieldvaluepassed.length; i++) {
		if( form.fieldvaluepassed[i].checked == true ) {
			return true;
		}
	}

	return false;

}
//END SEARCH SUBSCRIBER FUNCTION DEFINITIONS


//START MAIN FUNCTION FOR SEARCH SUBSCRIBERS FORM VALIDATION
function isSearchFormReady(form) {
	
    if (isFieldTypeValid(form) == false) {
        alert("Please choose a field type to search by");
		form.radiobutton[0].focus();
		return false;
    }

  
	return true;

}


//note: function will not work if you name it similar to existing function
function isSearchReady(form) {

    if (isFieldValid(form.fieldvaluepassed.value) == false) {
        alert("Please enter some valid input to search for");
		form.fieldvaluepassed.focus();
		return false;
    }

  
	return true;

}

//note: function will not work if you name it similar to existing function
function isSearchRadioReady(form) {

    if (isFieldRadioValid(form) == false) {
        alert("Please choose a radio button for the message type");
		form.fieldvaluepassed[0].focus();
		return false;
    }

  
	return true;

}
// END MAIN FUNCTION FOR SEARCH SUBSCRIBERS


// ----------------------------------------------------------------------------------------------------------------------------


//BEGIN SEND PLAIN EMAIL FORM VALIDATION FUNCTION DEFINITIONS

function isFromNameValid(string) {

   if (!string) return false;
   var iChars = "*|,\":<>[]{}`\';()@&$#%";

   for (var i = 0; i < string.length; i++) {
      if (iChars.indexOf(string.charAt(i)) != -1)
         return false;
   }
   return true;
} 


function isSubjectValid(string) {

   if (!string) return false;

   return true;
} 


function isMessageValid(string) {

   if (!string) return false;

   return true;
}       





//END SUB-FUNCTION DEFINITIONS

//START MAIN FUNCTION FOR SEND PLAIN EMAIL FORM VALIDATION
function isEmailReady(form) {


    if (isFromNameValid(form.fromName.value) == false) {
        alert("Please enter the from name for the email message.");
        form.fromName.focus();
        return false;
    }


    if (isEmailValid(form.fromEmail.value) == false) {
        alert("Please enter a valid email address.");
		form.fromEmail.focus();
		return false;
    }
	
	
    if (isSubjectValid(form.subject.value) == false) {
        alert("Please enter a subject for the email message.");
        form.subject.focus();
        return false;
    }
	
	if (isMessageValid(form.message.value) == false) {
        alert("Please enter some text for the email message.");
        form.message.focus();
        return false;
    }	


    return true;

}
// END MAIN FUNCTION FOR SEND PLAIN EMAIL 


// ----------------------------------------------------------------------------------------------------------------------------
