
function is_empty(ine_fld){ // == == == == == == == STANDALONE FUNCTION
	if( document.getElementById(ine_fld).value.length<1 ){
		return true ;
	} else {
		return false ;
	}
}

function is_minimum(ine_fld,ine_chars){ // == == == == == == == STANDALONE FUNCTION
	if( document.getElementById(ine_fld).value.length<ine_chars ){
		return false ;
	} else {
		return true ;
	}
}

function swap_menu(sm_master_id,sm_opt_array){ // == == == == == == == STANDALONE FUNCTION
	sm_opt_array = sm_opt_array.split('|') ;
	for ( var sm_i=0, sm_len=sm_opt_array.length; sm_i<sm_len; ++sm_i ){
		document.getElementById(sm_opt_array[sm_i]).style.display='none' ;
	}
	sm_master_val = document.getElementById(sm_master_id).value ;
	document.getElementById(sm_master_val).style.display='inline' ;
}

// Function returns true if variable 1 is higher than veriable 2, and lower than variable 3
function isBetween(ib_str,ib_low,ib_high){
	if( parseFloat(ib_str) >= ib_low && parseFloat(ib_str) <= ib_high ){
		return true ;
	} else {
		return false ;
	}
}

// Checks to see if the pressed key was an appication key, IE backspace, enter
function isAppKey(iak_str){ // 8 = backspace, 13 = enter
	iak_str = parseFloat(iak_str) ;
	if(iak_str==8 || iak_str==13 ){
		return true ;
	} else {
		return false ;
	}
}

function isNumberKey(evt){ // == == == == == == == REQUIRES : isBetween
	var charCode = (evt.which) ? evt.which : event.keyCode ;
	charCode = parseFloat(charCode) ;
	if (charCode > 33 && isBetween(charCode,48,57)==false ){
		return false;
	} else {
		return true;
	}
}

function isDecimalKey(evt2){ // == == == == == == == REQUIRES : isNumberKey, isBetween (for isNumberKey)
	var charCode2 = (evt2.which) ? evt2.which : event.keyCode ;
	charCode2 = parseFloat(charCode2) ;
	if( isNumberKey(evt2)==true || charCode2 == 46 ){
		return true;
	} else {
		return false;
	}
}

function isLetterKey(evt3){ // == == == == == == == REQUIRES : isBetween, isAppKey
	var charCode3 = (evt3.which) ? evt3.which : event.keyCode ;
	charCode3 = parseFloat(charCode3) ;
	if ( isAppKey(charCode3)==true || isBetween(charCode3,64,91)==true||isBetween(charCode3,96,123)==true ){
		return true;
	} else {
		return false;
	}
}

function isSpecifiedKey(evt4,isk_allowed){ // == == == == == == == STANDALONE FUNCTION
	isk_found = false ;
	var charCode4 = (evt4.which) ? evt4.which : event.keyCode ;
	charCode4 = parseFloat(charCode4) ;
	if( charCode4==8 ){ isk_found = true ; }
	isk_array = isk_allowed.split('|') ;
	for ( var isk_i=0, isk_len=isk_array.length; isk_i<isk_len; ++isk_i ){
		if( isk_array[isk_i]==String.fromCharCode(charCode4) ){ isk_found = true ; }
	}
	return isk_found ;
}

function checkMe(cm_id){
	cm_type = document.getElementById(cm_id).type ;
	cm_chk = document.getElementById(cm_id).checked ;
	if(cm_type=='radio'){
		if(cm_chk==false){document.getElementById(cm_id).checked=true}
	} else if (cm_type=='checkbox'){
		if(cm_chk==false){document.getElementById(cm_id).checked=true} else {document.getElementById(cm_id).checked=false}
	} else {
		alert('FIELD TYPE ERROR\nThis script only works on Checkbox and Radio type fields');
	}
}

function fill_if_null(fin_fld,fin_val,fin_opperator){ // fin_opperator = 0 (remove is present) = 1 (add if not)
	if( fin_opperator==0 ){
		if( document.getElementById(fin_fld).value==fin_val ){
			document.getElementById(fin_fld).value = '' ;
		}
	} else {
		if( document.getElementById(fin_fld).value==''||document.getElementById(fin_fld).value==null ){
			document.getElementById(fin_fld).value = fin_val ;
		}
	}
}

function echeck(ec_fldid) {
	var str = document.getElementById(ec_fldid).value ;
	var at="@" ;
	var dot="." ;
	var lat=str.indexOf(at) ;
	var lstr=str.length ;
	var ldot=str.indexOf(dot) ;
	if (is_empty(ec_fldid)){
		return false ;
	} else if (str.indexOf(at)==-1){
		return false ;
	} else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		return false ;
	} else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		return false ;
	} else if (str.indexOf(at,(lat+1))!=-1){
		return false ;
	} else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false ;
	} else if (str.indexOf(dot,(lat+2))==-1){
		return false ;
	} else if (str.indexOf(" ")!=-1){
		return false ;
	} else {
		return true	;	
	}
}
