function D(p_id) {
    return document.getElementById(p_id);
}

function isEmail(p_str, p_required) {
    if(p_required) {
        if(!isStringFilledIn(p_str)) {
            return -2;
        }
    }
    
	if(!p_str.match(/^[\w]{1,3}[\w\.\-_]*@[\w]{1,3}[\w\-_\.]*\.[\w]{2,6}$/i)) {
		return -1;
	} else {
		return 0;
	}
	
}

function isInteger(p_str, p_required) {
    if(p_required) {
        if(!isStringFilledIn(p_str)) {
            return -2;
        }
    }
    var v_tmp = parseInt(p_str, 10);
    if (v_tmp == p_str) {
        return 0;
    }
    return -1;
}

function isString(p_str, p_required) {
    if(p_required) {
        if(!isStringFilledIn(p_str)) {
            return -2;
        }
    }
    return 0;
}

function isStringFilledIn(p_str) {
    if(p_str.trim().length > 0) {
        return true;
    }
    return false;
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
