// Erstellt eine echte Array Kopie
Array.prototype.copy = function()
{
     var tmp = new Array();
     for (var i = 0; i < this.length; i++)  
     {
     	tmp[i] = this[i];
     }
     return tmp;
}

// Prueft ob der angegebene Wert im Array vorkommt, gibt true bzw. false zurueck
Array.prototype.in_array = function( arrayvalue ) 
{
	for (var i = 0; i < this.length; i++)
	{
		if (this[i] === arrayvalue)
		{
			return true;
		}
	}
	return false;
};

// sucht den Text und gibt den Index zurueck
Array.prototype.search = function( arrayvalue ) 
{
	for (var i = 0; i < this.length; i++)
	{
		if (this[i] === arrayvalue)
		{
			return i;
		}
	}
	return -1;
};

// Trimmt einen String
String.prototype.trim = function( )
{
	var oldstring = this;
	var newstring = '';
	for (var i = 0; i < oldstring.length; i++)
	{
		if (oldstring.substr(i, 1) != ' ')
		{
			newstring += oldstring.substr(i, 1);
		}
	}
	return newstring;
}

// String Rot 13 auf String, siehe PHP Doku
String.prototype.str_rot13 = function( )
{
	var text = this;
	var strtext = '';
	for (var i = 0; i < text.length; i++)
	{
		if (text.charCodeAt(i) >= 65 && text.charCodeAt(i) <= 90)
		{
			if (text.charCodeAt(i) + 13 > 90)
			{
				newcode = (65 - 1) + (13 - (90 - text.charCodeAt(i)));
				strtext = strtext + String.fromCharCode(newcode).toString();
			}
			else
			{
				strtext = strtext + String.fromCharCode(text.charCodeAt(i) + 13).toString();
			}
		}
		else if (text.charCodeAt(i) >= 97 && text.charCodeAt(i) <= 122)
		{
			if (text.charCodeAt(i) + 13 > 122)
			{
				newcode = (97 - 1) + (13 - (122 - text.charCodeAt(i)));
				strtext = strtext + String.fromCharCode(newcode).toString();
			}
			else
			{
				strtext = strtext + String.fromCharCode(text.charCodeAt(i) + 13).toString();
			}
		}
		else
		{
			strtext = strtext + text.charAt(i).toString();
		}
	}
	
	return strtext;
}


/**
 * Parst den String zu einem Floatwert
 */
String.prototype.parse2float = function()
{
	var text = this;
	var strtext = '';
	strtext = text.replace(/,/gi, '.');
	strtext = strtext.replace(/[^0-9\.]+/gi, '');
	if (strtext.indexOf('.') != strtext.lastIndexOf('.'))
	{
		var p1 = strtext.substr(0, strtext.lastIndexOf('.'));
		p1 = p1.replace(/\./gi, '');
		strtext = p1 + strtext.substr(strtext.lastIndexOf('.'));
	}
	
	return strtext;
}

/**
 * Parst den String zu einem Intwert
 */
String.prototype.parse2int = function()
{
	var text = this;
	
	text = text.replace(/[^0-9]/gi, '');
	
	return text;
}