String.prototype.trim = function() { return jQuery.trim(this); };
String.prototype.removeCarriage = function() { 
	o="";
	for (i=0;i<this.length;i++)
	{
		if (this.charCodeAt(i)== 10)
		{o+="  "}
		else {o+=this.charAt(i);}
	}
	return o; 
	};
String.prototype.addslashes = function() { 
	str=this.replace('\'','\'\'');
	return str; 
	};
String.prototype.stripslashes = function() { 
	str=this.replace('\'\'','\'');
	return str; 
	};
	


//MyValidation
function required(input,texts,m,style)
{
	$("#"+m).text("");
	for (i=0;i<input.length;i++)
	{
		$("#"+input[i]).css({ border: "" });
		if ($("#"+input[i]).val().trim()=="")
		{
			$("#"+input[i]).focus().css({ border: style });
			$("#"+m).html(texts[i]);
			return false;
		}
	}
	return true;
}

//FUNZIONE DI CONTROLLO EMAIL
function checkValidEmail(email)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(email))
	{return false;}
	return true;
}

function checkValidUsername(input)
	{
		if (input.length<2) {return false;}
		var numaric = input.trim();
		for(var j=0; j<numaric.length; j++)
			{
			  var alphaa = numaric.charAt(j);
			  var hh = alphaa.charCodeAt(0);
			  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
			  {
			  	k=0;
			  }
			  else{ return false; }
			}
	 return true;
	}