
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.replaceAll = function(strFind,strReplace){
    var temp = this;
    var index = temp.indexOf(strFind);
    while(index != -1){
        temp = temp.replace(strFind,strReplace);
        index = temp.indexOf(strFind);
    }
    return temp;
}
String.prototype.lPad = function(size,c){
	var result = this.split('');
	for(var i = 0; i < size - this.length; i++){
		result.unshift (c)
	};
	return result.join('');
}

String.prototype.rPad = function(size,c){
	var i;
	var a = this.split('');
	for(i = 0; i < size - this.length; i++){
		a.push (c);
	}
	return a.join('');
}

function validaCampo( id ) {
	var value = $("#"+id ).val();
	if( value != null && value.trim() != "") {
		return true;
	} else {
		return false;
	}
}

function validaCampoRadio( name ) {
	if($('input[name='+name+']:checked').size() == 0) {
		return false;
	} 
	return true;
}

function enviarForm(url) {
	window.location = url;
}

function somente_numero(campo){
	$(campo).val($(campo).val().replace(/[^0-9]/g, ''));
}

function formata_data(v){
	if(v.length <= 10) {
	    v=v.replace(/\D/g,"")
	    v=v.replace(/(\d{2})(\d)/,"$1/$2") 
	    v=v.replace(/(\d{2})(\d)/,"$1/$2")
	    v=v.replace(/(\d{4})(\d)/,"$1/$2")
	    return v;
    }
}
function random(size){
	var num = Math.floor(Math.random() * (size-1));
	return parseInt(num) + 1;
}

