Object.prototype.extend = function (objeto)
{
	for (propiedad in objeto)
	{
		this[propiedad] = objeto[propiedad];
	}
}

Object.prototype.define = function (nombre, valor)
{
	if(!this[nombre.toUpperCase()]) this[nombre.toUpperCase()] = valor;
	else throw 'Constante ya definida';
}

Array.prototype.search = function (texto)
{
	retorno = -1;
	i=0;
	while(i<this.length && retorno==-1)
	{
		if(this[i] == texto) retorno = i;
		i++;
	}
	return retorno;
}

Array.prototype.key_exists = keyExists;
Object.prototype.key_exists = keyExists;
function keyExists(isKey, array)
{
	var array = array ? array : this;
	var retorno = false;
	for(key in array)
	{
		if(key==isKey && array[key] != null)
		{
			retorno = array[key];
		}
	}
	return retorno;
}

String.prototype.trim = trim;
function trim(valor)
{
	var re = /^(\s)*|(\s)*$/;
	var str = (valor ? valor : this);
	return str.replace(re,'');
}

String.prototype.pad = pad;
function pad(caracter, longitud, lado, string)
{
	var str = 'undefined'!=typeof string ? string : this;
	while(str.length<longitud)
	{
		str = (lado?str:'') + caracter + (!lado?str:'');
	}
	return str;
}

String.prototype.ucfirst = ucfirst;
function ucfirst(string)
{
	var str = string ? string : this;
	return str.charAt(0).toUpperCase() + str.substring(1);
}

Date.prototype.getSimpleDate = function ()
{
	var retorno = this.getFullYear().toString() + '/' + this.getMonth().toString().pad('0',2) + '/' + this.getDate().toString().pad('0',2);
	    retorno += ' - ';
	    retorno += this.getHours().toString().pad('0',2) + ':' + this.getMinutes().toString().pad('0',2) + ':' + this.getSeconds().toString().pad('0',2) + '.' + this.getMilliseconds().toString().pad('0',3);
	return retorno;
}
