﻿// <!--

function isValidEmail(val, emailValidationRegExp) {
	return (val.match(emailValidationRegExp) != null);
}

// CAN NOT USE THIS FUNCTION - IT IS A jQuery Function
//function $(id) {
    //return document.getElementById(id);
//}

function $$(id) {
	return document.getElementById(id);
}

function trim(value) {
    return rtrim(ltrim(value));
}

function ltrim(value) {
    var v_length = value.length;
    if (v_length < 1) {
        return "";
    }
    var w_space = String.fromCharCode(32);
    var strTemp = "";

    var iTemp = 0;

    while (iTemp < v_length) {
        if (value.charAt(iTemp) != w_space) {
            strTemp = value.substring(iTemp, v_length);
            break;
        }
        iTemp = iTemp + 1;
    } //End While

    return strTemp;

}

function rtrim(value) {
    var w_space = String.fromCharCode(32);
    if (v_length < 1) {
        return "";
    }

    var strTemp = value;
    var v_length = value.length;
    var iTemp = v_length;

    while (iTemp > 0) {
        if (value.charAt(iTemp) != w_space) {
            strTemp = value.substring(0, iTemp);
            break;
        } else if (iTemp == 1) {
            strTemp = "";
            break;
        } else {
            iTemp = iTemp - 1;
        }
    } //End While

    return strTemp;
}

function isEmail(elm, emailValidationRegExp) {
	return (elm.value.match(emailValidationRegExp) != null);	
} 

function isFilled(elm) {
	if (elm.value == "" || elm.value == null)
		return false;
	return true;
}

function clickControlOnEnter(event, id) {
	if (isEnter(event)) {
		document.getElementById(id).click();
		return false;
	}
}

function isEnter(event) {
	if (event.keyCode == 13) {
		return true;
	}
	return false;
}

// -->