
function validate_email(field,alerttxt) {
	with (field) {
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
			
		if (apos<1||dotpos-apos<2) {
			alert(alerttxt);
			return false;
		} else {
			return true;
		}
	}
}

function validate_field(field,alerttxt) {
	with (field) {
		if (value==null||value=="") {			
			alert(alerttxt);
			return false;
		} else {
			return true;
		}
	}
}

function validate_firstname(field,alerttxt) {
	with (field) {
		if (value==null||value=="") {			
			alert(alerttxt);
			return false;
		} else {
			return true;
		}
	}
}

function validate_lastname(field,alerttxt) {
	with (field) {
		if (value==null||value=="") {			
			alert(alerttxt);
			return false;
		} else {
			return true;
		}
	}
}

function validate_phone(field, alerttxt){
	with(field) {
		// THERE IS A VALUE NOW CHECK IF ITS VALID
		if(value.length > 9) {
			valid_chars = "0123456789.-()ext# ";
			
			var char_status = "valid";
			// LOOP THROUGH STRING TO FIND VALID CHARACTERS
			for(i=0;i<value.length;i++){
				if(valid_chars.indexOf(value.charAt(i)) < 0){
					// AN INVALID CHARACTER WAS FOUND, ALERT USER
					char_status = "invalid";
				}
			}
			
			if(char_status == "invalid"){
				alert(alerttxt);
				return false;
			}
		} else {
			alert(alerttxt);
			return false;
		}
	}
}

function validate_dropdown(field, alerttxt){
	with(field){
		if(field.selectedIndex == 0){
			alert(alerttxt);
			return false;
		}
	}
}

function validate_number(field, alerttxt){
	with(field) {
		// THERE IS A VALUE NOW CHECK IF ITS VALID
		if(value.length > 4) {
			valid_chars = "0123456789-";
			
			var char_status = "valid";
			// LOOP THROUGH STRING TO FIND VALID CHARACTERS
			for(i=0;i<value.length;i++){
				if(valid_chars.indexOf(value.charAt(i)) < 0){
					// AN INVALID CHARACTER WAS FOUND, ALERT USER
					char_status = "invalid";
					
				}
			}
			
			if(char_status == "invalid"){
				alert(alerttxt);
				return false;
			}
		} else {
			alert(alerttxt);
			return false;
		}
	}
}

function validate_character(field, alerttxt){
	with(field) {
		// THERE IS A VALUE NOW CHECK IF ITS VALID
		if(value.length > 4) {
			valid_chars = "dfdaa10561ds./,";
			
			var char_status = "valid";
			// LOOP THROUGH STRING TO FIND VALID CHARACTERS
			for(i=0;i<value.length;i++){
				if(valid_chars.indexOf(value.charAt(i)) < 0){
					// AN INVALID CHARACTER WAS FOUND, ALERT USER
					char_status = "invalid";
					
				}
			}
			
			if(char_status == "invalid"){
				alert(alerttxt);
				return false;
			}
		} else {
			alert(alerttxt);
			return false;
		}
	}
}
