String.prototype.isEmail = function() {
    var exp  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if( exp.test( this ) ) {
        return true;
    }
    return false;
}

String.prototype.isEmpty = function() {
    return ( this.replace(/^\s+|\s+$/g,"").length == 0 )? true:false; 
}

String.prototype.isPhone = function() {
    var exp1  = /^\+([0-9]{2})+\.([0-9]{2})+\.([0-9]{7})+$/;
    var exp2  = /^\+([0-9]{2})+\.([0-9]{9})+$/;
    if( exp1.test( this ) || exp2.test( this ) ) {
    
        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+$/,"");
}

String.prototype.isNIP = function() {

    if( this.length > 13 ) {
        return false;
    }

    var Arg = this.replace(/-/g,'');

    if ( !Arg.match( /^[0-9]{10}$/ ) )  {
        return false;
    }

    var weights  = "657234567";
    var checksum = 0;

    for ( var idx = 0; idx < 9; idx++ ) {
        checksum += ( parseInt(weights.charAt(idx)) * parseInt(Arg.charAt(idx)) );
    }

    if ( ((checksum % 11) % 10) == parseInt(Arg.charAt(9))) {
        return true;
    }

    return false;
}
